true and false support, and lowering for bool type. (#2896)

This commit is contained in:
Richard Smith
2023-06-13 16:43:03 -07:00
committed by GitHub
parent 8e940d9724
commit aa40e2b8a9
15 changed files with 198 additions and 5 deletions
+20
View File
@@ -68,6 +68,23 @@ struct SemanticsCrossReferenceIRId : public IndexBase {
}
};
// A boolean value.
struct SemanticsBoolValue : public IndexBase {
using IndexBase::IndexBase;
auto Print(llvm::raw_ostream& out) const -> void {
switch (index) {
case 0:
out << "false";
break;
case 1:
out << "true";
break;
default:
CARBON_FATAL() << "Invalid bool value " << index;
}
}
};
// The ID of an integer literal.
struct SemanticsIntegerLiteralId : public IndexBase {
using IndexBase::IndexBase;
@@ -264,6 +281,9 @@ class SemanticsNode {
using BlockArg = Factory<SemanticsNodeKind::BlockArg>;
using BoolLiteral =
Factory<SemanticsNodeKind::BoolLiteral, SemanticsBoolValue /*value*/>;
using Branch = FactoryNoType<SemanticsNodeKind::Branch,
SemanticsNodeBlockId /*target_id*/>;