Rename lower to lowering (#2618)

Also Lower::Make to LowerToLLVM, removing the class for now.

This is per request from chandlerc and zygoloid.
This commit is contained in:
Jon Ross-Perkins
2023-02-22 12:19:35 -08:00
committed by GitHub
parent 2adaeee2ba
commit 86aecb532f
12 changed files with 28 additions and 31 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ def add_substitutions():
add_substitution("carbon", f"{run_carbon}")
add_substitution(
"carbon-run-lower",
"carbon-run-lowering",
f"{run_carbon} dump llvm-ir %s | {filecheck_strict}",
)
add_substitution(
+1 -1
View File
@@ -19,7 +19,7 @@ cc_library(
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:sorting_diagnostic_consumer",
"//toolchain/lexer:tokenized_buffer",
"//toolchain/lower",
"//toolchain/lowering:lower_to_llvm",
"//toolchain/parser:parse_tree",
"//toolchain/semantics:semantics_ir",
"//toolchain/source:source_buffer",
+4 -4
View File
@@ -15,7 +15,7 @@
#include "llvm/Support/Format.h"
#include "toolchain/diagnostics/sorting_diagnostic_consumer.h"
#include "toolchain/lexer/tokenized_buffer.h"
#include "toolchain/lower/lower.h"
#include "toolchain/lowering/lower_to_llvm.h"
#include "toolchain/parser/parse_tree.h"
#include "toolchain/semantics/semantics_ir.h"
#include "toolchain/source/source_buffer.h"
@@ -209,11 +209,11 @@ auto Driver::RunDumpSubcommand(DiagnosticConsumer& consumer,
}
CARBON_VLOG() << "semantics_ir: " << semantics_ir;
CARBON_VLOG() << "*** Lower::Make ***\n";
CARBON_VLOG() << "*** LowerToLLVM ***\n";
llvm::LLVMContext llvm_context;
const std::unique_ptr<llvm::Module> module =
Lower::Make(llvm_context, input_file_name, semantics_ir);
CARBON_VLOG() << "*** Lower::Make done ***\n";
LowerToLLVM(llvm_context, input_file_name, semantics_ir);
CARBON_VLOG() << "*** LowerToLLVM done ***\n";
if (dump_mode == DumpMode::LLVMIR) {
consumer.Flush();
module->print(output_stream_, /*AAW=*/nullptr,
-8
View File
@@ -1,8 +0,0 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-lower}
// CHECK:STDOUT: ; ModuleID = '{{.*}}/toolchain/lower/testdata/basics/empty.carbon'
// CHECK:STDOUT: source_filename = "{{.*}}/toolchain/lower/testdata/basics/empty.carbon"
@@ -5,9 +5,9 @@
package(default_visibility = ["//visibility:public"])
cc_library(
name = "lower",
srcs = ["lower.cpp"],
hdrs = ["lower.h"],
name = "lower_to_llvm",
srcs = ["lower_to_llvm.cpp"],
hdrs = ["lower_to_llvm.h"],
deps = [
"//common:check",
"//common:ostream",
@@ -22,12 +22,12 @@ def main() -> None:
)
args = [
sys.argv[0],
# Flags to configure for lower testing.
# Flags to configure for lowering testing.
"--tool=carbon",
"--autoupdate_arg=dump",
"--autoupdate_arg=llvm-ir",
"--lit_run=%{carbon-run-lower}",
"--testdata=toolchain/lower/testdata",
"--lit_run=%{carbon-run-lowering}",
"--testdata=toolchain/lowering/testdata",
] + sys.argv[1:]
os.execv(actual_py, args)
@@ -2,11 +2,11 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/lower/lower.h"
#include "toolchain/lowering/lower_to_llvm.h"
namespace Carbon {
auto Lower::Make(llvm::LLVMContext& llvm_context, llvm::StringRef module_name,
auto LowerToLLVM(llvm::LLVMContext& llvm_context, llvm::StringRef module_name,
const SemanticsIR& /*semantics_ir*/)
-> std::unique_ptr<llvm::Module> {
auto result = std::make_unique<llvm::Module>(module_name, llvm_context);
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_LOWER_LOWER_H_
#define CARBON_TOOLCHAIN_LOWER_LOWER_H_
#ifndef CARBON_TOOLCHAIN_LOWERING_LOWER_TO_LLVM_H_
#define CARBON_TOOLCHAIN_LOWERING_LOWER_TO_LLVM_H_
#include "common/ostream.h"
#include "llvm/IR/LLVMContext.h"
@@ -13,13 +13,10 @@
namespace Carbon {
// Lowers Semantics IR to LLVM IR.
class Lower {
public:
static auto Make(llvm::LLVMContext& llvm_context, llvm::StringRef module_name,
const SemanticsIR& semantics_ir)
-> std::unique_ptr<llvm::Module>;
};
auto LowerToLLVM(llvm::LLVMContext& llvm_context, llvm::StringRef module_name,
const SemanticsIR& semantics_ir)
-> std::unique_ptr<llvm::Module>;
} // namespace Carbon
#endif // CARBON_TOOLCHAIN_LOWER_LOWER_H_
#endif // CARBON_TOOLCHAIN_LOWERING_LOWER_TO_LLVM_H_
+8
View File
@@ -0,0 +1,8 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// RUN: %{carbon-run-lowering}
// CHECK:STDOUT: ; ModuleID = '{{.*}}/toolchain/lowering/testdata/basics/empty.carbon'
// CHECK:STDOUT: source_filename = "{{.*}}/toolchain/lowering/testdata/basics/empty.carbon"