diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-02-03 13:56:56 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-02-03 13:56:56 -0500 |
| commit | 8c9016b6d1a62da847faf95b6124515cdcd9fe0b (patch) | |
| tree | 315daeb2627a150321bc2af9a1ab9563b041fc81 /src/ir_print.cpp | |
| parent | 3be4b6434c0d96f8f6975c13c1a84f06a9857ed8 (diff) | |
| download | zig-8c9016b6d1a62da847faf95b6124515cdcd9fe0b.tar.gz zig-8c9016b6d1a62da847faf95b6124515cdcd9fe0b.zip | |
add setGlobalAlign and setGlobalSection builtin functions
closes #241
Diffstat (limited to 'src/ir_print.cpp')
| -rw-r--r-- | src/ir_print.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/src/ir_print.cpp b/src/ir_print.cpp index 79e0bdb895..fa7ff97d81 100644 --- a/src/ir_print.cpp +++ b/src/ir_print.cpp @@ -233,11 +233,15 @@ static void ir_print_phi(IrPrint *irp, IrInstructionPhi *phi_instruction) { static void ir_print_container_init_list(IrPrint *irp, IrInstructionContainerInitList *instruction) { ir_print_other_instruction(irp, instruction->container_type); fprintf(irp->f, "{"); - for (size_t i = 0; i < instruction->item_count; i += 1) { - IrInstruction *item = instruction->items[i]; - if (i != 0) - fprintf(irp->f, ", "); - ir_print_other_instruction(irp, item); + if (instruction->item_count > 50) { + fprintf(irp->f, "...(%zu items)...", instruction->item_count); + } else { + for (size_t i = 0; i < instruction->item_count; i += 1) { + IrInstruction *item = instruction->items[i]; + if (i != 0) + fprintf(irp->f, ", "); + ir_print_other_instruction(irp, item); + } } fprintf(irp->f, "}"); } @@ -827,6 +831,18 @@ static void ir_print_can_implicit_cast(IrPrint *irp, IrInstructionCanImplicitCas fprintf(irp->f, ")"); } +static void ir_print_set_global_align(IrPrint *irp, IrInstructionSetGlobalAlign *instruction) { + fprintf(irp->f, "@setGlobalAlign(%s,", buf_ptr(&instruction->var->name)); + ir_print_other_instruction(irp, instruction->value); + fprintf(irp->f, ")"); +} + +static void ir_print_set_global_section(IrPrint *irp, IrInstructionSetGlobalSection *instruction) { + fprintf(irp->f, "@setGlobalSection(%s,", buf_ptr(&instruction->var->name)); + ir_print_other_instruction(irp, instruction->value); + fprintf(irp->f, ")"); +} + static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { ir_print_prefix(irp, instruction); switch (instruction->id) { @@ -1093,6 +1109,12 @@ static void ir_print_instruction(IrPrint *irp, IrInstruction *instruction) { case IrInstructionIdCanImplicitCast: ir_print_can_implicit_cast(irp, (IrInstructionCanImplicitCast *)instruction); break; + case IrInstructionIdSetGlobalAlign: + ir_print_set_global_align(irp, (IrInstructionSetGlobalAlign *)instruction); + break; + case IrInstructionIdSetGlobalSection: + ir_print_set_global_section(irp, (IrInstructionSetGlobalSection *)instruction); + break; } fprintf(irp->f, "\n"); } |
