aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/ir_print.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-03-28 21:42:56 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-03-28 21:42:56 -0700
commitb85ef2300fa72f5f4c73b8eb9e14f0218ada592d (patch)
treedaee8ab81eaefb5433f6ba3750656ba769a311a4 /src/stage1/ir_print.cpp
parent75080e351af8be45722bca50c1d5fcd503304d77 (diff)
parent175adc0bd738c2e3a55bb71c6a53dcc920c203ba (diff)
downloadzig-b85ef2300fa72f5f4c73b8eb9e14f0218ada592d.tar.gz
zig-b85ef2300fa72f5f4c73b8eb9e14f0218ada592d.zip
Merge remote-tracking branch 'origin/master' into llvm12
Diffstat (limited to 'src/stage1/ir_print.cpp')
-rw-r--r--src/stage1/ir_print.cpp59
1 files changed, 49 insertions, 10 deletions
diff --git a/src/stage1/ir_print.cpp b/src/stage1/ir_print.cpp
index 98d349012e..22b6c1ed5f 100644
--- a/src/stage1/ir_print.cpp
+++ b/src/stage1/ir_print.cpp
@@ -270,8 +270,10 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcIntToErr";
case IrInstSrcIdErrToInt:
return "SrcErrToInt";
- case IrInstSrcIdCheckSwitchProngs:
- return "SrcCheckSwitchProngs";
+ case IrInstSrcIdCheckSwitchProngsUnderNo:
+ return "SrcCheckSwitchProngsUnderNo";
+ case IrInstSrcIdCheckSwitchProngsUnderYes:
+ return "SrcCheckSwitchProngsUnderYes";
case IrInstSrcIdCheckStatementIsVoid:
return "SrcCheckStatementIsVoid";
case IrInstSrcIdTypeName:
@@ -298,6 +300,10 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcSetEvalBranchQuota";
case IrInstSrcIdPtrType:
return "SrcPtrType";
+ case IrInstSrcIdPtrTypeSimple:
+ return "SrcPtrTypeSimple";
+ case IrInstSrcIdPtrTypeSimpleConst:
+ return "SrcPtrTypeSimpleConst";
case IrInstSrcIdAlignCast:
return "SrcAlignCast";
case IrInstSrcIdImplicitCast:
@@ -308,8 +314,10 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcResetResult";
case IrInstSrcIdSetAlignStack:
return "SrcSetAlignStack";
- case IrInstSrcIdArgType:
- return "SrcArgType";
+ case IrInstSrcIdArgTypeAllowVarFalse:
+ return "SrcArgTypeAllowVarFalse";
+ case IrInstSrcIdArgTypeAllowVarTrue:
+ return "SrcArgTypeAllowVarTrue";
case IrInstSrcIdExport:
return "SrcExport";
case IrInstSrcIdExtern:
@@ -2187,7 +2195,9 @@ static void ir_print_err_to_int(IrPrintGen *irp, IrInstGenErrToInt *instruction)
ir_print_other_inst_gen(irp, instruction->target);
}
-static void ir_print_check_switch_prongs(IrPrintSrc *irp, IrInstSrcCheckSwitchProngs *instruction) {
+static void ir_print_check_switch_prongs(IrPrintSrc *irp, IrInstSrcCheckSwitchProngs *instruction,
+ bool have_underscore_prong)
+{
fprintf(irp->f, "@checkSwitchProngs(");
ir_print_other_inst_src(irp, instruction->target_value);
fprintf(irp->f, ",");
@@ -2200,6 +2210,8 @@ static void ir_print_check_switch_prongs(IrPrintSrc *irp, IrInstSrcCheckSwitchPr
}
const char *have_else_str = instruction->else_prong != nullptr ? "yes" : "no";
fprintf(irp->f, ")else:%s", have_else_str);
+ const char *have_under_str = have_underscore_prong ? "yes" : "no";
+ fprintf(irp->f, " _:%s", have_under_str);
}
static void ir_print_check_statement_is_void(IrPrintSrc *irp, IrInstSrcCheckStatementIsVoid *instruction) {
@@ -2237,6 +2249,15 @@ static void ir_print_ptr_type(IrPrintSrc *irp, IrInstSrcPtrType *instruction) {
ir_print_other_inst_src(irp, instruction->child_type);
}
+static void ir_print_ptr_type_simple(IrPrintSrc *irp, IrInstSrcPtrTypeSimple *instruction,
+ bool is_const)
+{
+ fprintf(irp->f, "&");
+ const char *const_str = is_const ? "const " : "";
+ fprintf(irp->f, "*%s", const_str);
+ ir_print_other_inst_src(irp, instruction->child_type);
+}
+
static void ir_print_decl_ref(IrPrintSrc *irp, IrInstSrcDeclRef *instruction) {
const char *ptr_str = (instruction->lval != LValNone) ? "ptr " : "";
fprintf(irp->f, "declref %s%s", ptr_str, buf_ptr(instruction->tld->name));
@@ -2344,11 +2365,17 @@ static void ir_print_set_align_stack(IrPrintSrc *irp, IrInstSrcSetAlignStack *in
fprintf(irp->f, ")");
}
-static void ir_print_arg_type(IrPrintSrc *irp, IrInstSrcArgType *instruction) {
+static void ir_print_arg_type(IrPrintSrc *irp, IrInstSrcArgType *instruction, bool allow_var) {
fprintf(irp->f, "@ArgType(");
ir_print_other_inst_src(irp, instruction->fn_type);
fprintf(irp->f, ",");
ir_print_other_inst_src(irp, instruction->arg_index);
+ fprintf(irp->f, ",");
+ if (allow_var) {
+ fprintf(irp->f, "allow_var=true");
+ } else {
+ fprintf(irp->f, "allow_var=false");
+ }
fprintf(irp->f, ")");
}
@@ -2885,8 +2912,11 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdErrToInt:
ir_print_err_to_int(irp, (IrInstSrcErrToInt *)instruction);
break;
- case IrInstSrcIdCheckSwitchProngs:
- ir_print_check_switch_prongs(irp, (IrInstSrcCheckSwitchProngs *)instruction);
+ case IrInstSrcIdCheckSwitchProngsUnderNo:
+ ir_print_check_switch_prongs(irp, (IrInstSrcCheckSwitchProngs *)instruction, false);
+ break;
+ case IrInstSrcIdCheckSwitchProngsUnderYes:
+ ir_print_check_switch_prongs(irp, (IrInstSrcCheckSwitchProngs *)instruction, true);
break;
case IrInstSrcIdCheckStatementIsVoid:
ir_print_check_statement_is_void(irp, (IrInstSrcCheckStatementIsVoid *)instruction);
@@ -2900,6 +2930,12 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdPtrType:
ir_print_ptr_type(irp, (IrInstSrcPtrType *)instruction);
break;
+ case IrInstSrcIdPtrTypeSimple:
+ ir_print_ptr_type_simple(irp, (IrInstSrcPtrTypeSimple *)instruction, false);
+ break;
+ case IrInstSrcIdPtrTypeSimpleConst:
+ ir_print_ptr_type_simple(irp, (IrInstSrcPtrTypeSimple *)instruction, true);
+ break;
case IrInstSrcIdDeclRef:
ir_print_decl_ref(irp, (IrInstSrcDeclRef *)instruction);
break;
@@ -2942,8 +2978,11 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdSetAlignStack:
ir_print_set_align_stack(irp, (IrInstSrcSetAlignStack *)instruction);
break;
- case IrInstSrcIdArgType:
- ir_print_arg_type(irp, (IrInstSrcArgType *)instruction);
+ case IrInstSrcIdArgTypeAllowVarFalse:
+ ir_print_arg_type(irp, (IrInstSrcArgType *)instruction, false);
+ break;
+ case IrInstSrcIdArgTypeAllowVarTrue:
+ ir_print_arg_type(irp, (IrInstSrcArgType *)instruction, true);
break;
case IrInstSrcIdExport:
ir_print_export(irp, (IrInstSrcExport *)instruction);