Split Semantics into Check and SemIR namespaces (#3138)

Splits IR files into SemIR, and logic files into Check. These will be
split into separate directories as part of a later move; the namespaces
are being done first in order to vet the switch, and hopefully make
conflicts a little easier to manage due to the substantial renames.

A lot of this is just automated removal of Semantics prefixes from
names, adding namespace references where needed. A few special-cases
are:

- SemanticsIR -> SemIR::File
- A few things were discussed, like Unit, CompileUnit, or CompiledUnit.
Unit was too vague for chandlerc, and I thought CompileUnit might lead
to incorrect inferences (CompilationUnit would be more precise, but
typically written as SemIR::CompilationUnit which is pretty long). File
seemed to be a short name that we could agree on.
- SemanticsIRFormatter -> SemIR::Formatter
- FormatSemanticsIR -> SemIR::FormatFile
- SemanticsFileTest -> CheckFileTest
- It remains in the Testing namespace, where just "FileTest" might be
too broad a name.
- SemanticsDeclarationNameStack::Context ->
Check::DeclarationNameStack::NameContext
  - This avoids a Check::Context name shadowing.

Changes check_internal.h to include ostream.h to improve finding of
Print/operator<< (otherwise it didn't compile).

This is part of #3070
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2023-08-23 22:51:23 +00:00
1 parent b2db2ca7cf
commit 67da700dd5
53 files changed
+1337 -1466

No files matched your search

@@ -14,7 +14,7 @@ LoweringFunctionContext::LoweringFunctionContext(
function_(function),
builder_(lowering_context.llvm_context()) {}
auto LoweringFunctionContext::GetBlock(SemanticsNodeBlockId block_id)
auto LoweringFunctionContext::GetBlock(SemIR::NodeBlockId block_id)
-> llvm::BasicBlock* {
llvm::BasicBlock*& entry = blocks_[block_id];
if (!entry) {
@@ -23,7 +23,7 @@ auto LoweringFunctionContext::GetBlock(SemanticsNodeBlockId block_id)
return entry;
}
auto LoweringFunctionContext::TryToReuseBlock(SemanticsNodeBlockId block_id,
auto LoweringFunctionContext::TryToReuseBlock(SemIR::NodeBlockId block_id,
llvm::BasicBlock* block) -> bool {
if (!blocks_.insert({block_id, block}).second) {
return false;
@@ -34,8 +34,8 @@ auto LoweringFunctionContext::TryToReuseBlock(SemanticsNodeBlockId block_id,
return true;
}
auto LoweringFunctionContext::GetBlockArg(SemanticsNodeBlockId block_id,
SemanticsTypeId type_id)
auto LoweringFunctionContext::GetBlockArg(SemIR::NodeBlockId block_id,
SemIR::TypeId type_id)
-> llvm::PHINode* {
llvm::BasicBlock* block = GetBlock(block_id);
@@ -60,7 +60,7 @@ auto LoweringFunctionContext::CreateSyntheticBlock() -> llvm::BasicBlock* {
return synthetic_block_;
}
auto LoweringFunctionContext::GetLocalLoaded(SemanticsNodeId node_id)
auto LoweringFunctionContext::GetLocalLoaded(SemIR::NodeId node_id)
-> llvm::Value* {
auto* value = GetLocal(node_id);
if (llvm::isa<llvm::AllocaInst, llvm::GetElementPtrInst>(value)) {