diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-12-29 12:32:55 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-12-29 12:32:55 +0000 |
commit | fcfbafff31869ed808bff0639532db1828660e92 (patch) | |
tree | 7425b346b031c4cb47a06250b3f6f950374d44ae /compiler_and_linker/unsorted/PCodeInfo.c | |
parent | bc1321735c15104ffad195e1509cab5f3a044260 (diff) | |
download | MWCC-fcfbafff31869ed808bff0639532db1828660e92.tar.gz MWCC-fcfbafff31869ed808bff0639532db1828660e92.zip |
dump lots more code
Diffstat (limited to 'compiler_and_linker/unsorted/PCodeInfo.c')
-rw-r--r-- | compiler_and_linker/unsorted/PCodeInfo.c | 185 |
1 files changed, 74 insertions, 111 deletions
diff --git a/compiler_and_linker/unsorted/PCodeInfo.c b/compiler_and_linker/unsorted/PCodeInfo.c index 3646930..c93176c 100644 --- a/compiler_and_linker/unsorted/PCodeInfo.c +++ b/compiler_and_linker/unsorted/PCodeInfo.c @@ -1,8 +1,18 @@ -#include "compiler.h" -#include "compiler/objects.h" #include "compiler/PCodeInfo.h" -#include "compiler/PCodeUtilities.h" #include "compiler/CError.h" +#include "compiler/CMangler.h" +#include "compiler/CParser.h" +#include "compiler/Alias.h" +#include "compiler/CodeGen.h" +#include "compiler/CompilerTools.h" +#include "compiler/PCode.h" +#include "compiler/PCodeListing.h" +#include "compiler/PCodeUtilities.h" +#include "compiler/RegisterInfo.h" +#include "compiler/StackFrame.h" +#include "compiler/TOC.h" +#include "compiler/objects.h" +#include "compiler/types.h" #pragma pool_strings on @@ -38,8 +48,7 @@ void pcode_get_hi_lo(int bits, char typechar, SInt32 *hi, SInt32 *lo) { *lo = -(1 << (bits - 1)); } } else { -#line 65 - CError_FATAL(); + CError_FATAL(65); } } @@ -83,8 +92,7 @@ int pcode_check_imm_bits(SInt32 value, int bits, char typechar) { if (forcedBits > 0 && value != ((value >> forcedBits) << forcedBits)) return 1; } else if (bits > 32) { -#line 110 - CError_FATAL(); + CError_FATAL(110); } return 0; @@ -154,10 +162,8 @@ PCode *vformatpcode(short opcode, va_list argList) { lastArg = pcode->args + pcode->argCount; arg = pcode->args; while (*format) { - if (arg >= lastArg) { -#line 189 - CError_FATAL(); - } + if (arg >= lastArg) + CError_FATAL(189); if (*format == ',' || *format == ';') format++; @@ -274,12 +280,10 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->data.reg.effect = effect; break; case 'P': - if (isdigit(format[1])) { + if (isdigit(format[1])) format += pcode_const_from_format(format + 1, &thing); - } else { -#line 319 - CError_FATAL(); - } + else + CError_FATAL(319); tmp = va_arg(argList, int); tmp2 = -1; for (i = 0; i < 4; i++) { @@ -318,8 +322,7 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->data.reg.reg = 0x11D; arg->data.reg.effect = effect; } else { -#line 353 - CError_FATAL(); + CError_FATAL(353); } pcsetsideeffects(pcode); arg->kind = PCOp_SYSREG; @@ -330,12 +333,10 @@ PCode *vformatpcode(short opcode, va_list argList) { case 'S': tmp2 = -1; - if (isdigit(format[1])) { + if (isdigit(format[1])) format += pcode_const_from_format(format + 1, &thing2); - } else { -#line 371 - CError_FATAL(); - } + else + CError_FATAL(371); for (i = 0; i < 4; i++) { if (thing2 == spr_to_sysreg[i]) { @@ -368,12 +369,10 @@ PCode *vformatpcode(short opcode, va_list argList) { tmp2 = (unsigned char) c; thing3 = 16; if (*format == 'a') { - if (isdigit(format[1])) { + if (isdigit(format[1])) tmp2 = (unsigned char) *(++format); - } else { -#line 408 - CError_FATAL(); - } + else + CError_FATAL(408); } if (isdigit(format[1])) { format += pcode_const_from_format(format + 1, &thing3); @@ -381,30 +380,24 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->kind = PCOp_IMMEDIATE; arg->data.imm.value = va_arg(argList, int); arg->data.imm.obj = NULL; - if (pcode_check_imm_bits(arg->data.imm.value, thing3, tmp2)) { -#line 419 - CError_FATAL(); - } + if (pcode_check_imm_bits(arg->data.imm.value, thing3, tmp2)) + CError_FATAL(419); break; case 'N': arg->kind = PCOp_IMMEDIATE; arg->data.imm.value = va_arg(argList, int); arg->data.imm.obj = NULL; - if (pcode_check_imm_bits(arg->data.imm.value, 6, 'u')) { -#line 429 - CError_FATAL(); - } + if (pcode_check_imm_bits(arg->data.imm.value, 6, 'u')) + CError_FATAL(429); break; case 'D': arg->kind = PCOp_IMMEDIATE; arg->data.imm.value = va_arg(argList, int); arg->data.imm.obj = NULL; - if (pcode_check_imm_bits(arg->data.imm.value, 10, 'u')) { -#line 438 - CError_FATAL(); - } + if (pcode_check_imm_bits(arg->data.imm.value, 10, 'u')) + CError_FATAL(438); break; case 'B': @@ -412,10 +405,8 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->kind = PCOp_IMMEDIATE; arg->data.imm.value = va_arg(argList, int); arg->data.imm.obj = NULL; - if (pcode_check_imm_bits(arg->data.imm.value, 5, 'u')) { -#line 448 - CError_FATAL(); - } + if (pcode_check_imm_bits(arg->data.imm.value, 5, 'u')) + CError_FATAL(448); break; case 'Q': @@ -428,10 +419,8 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->kind = PCOp_IMMEDIATE; arg->data.imm.value = va_arg(argList, int); arg->data.imm.obj = NULL; - if (pcode_check_imm_bits(arg->data.imm.value, 4, 'u')) { -#line 463 - CError_FATAL(); - } + if (pcode_check_imm_bits(arg->data.imm.value, 4, 'u')) + CError_FATAL(463); break; case 'l': @@ -441,8 +430,7 @@ PCode *vformatpcode(short opcode, va_list argList) { } else { arg->kind = PCOp_MEMORY; obj = va_arg(argList, Object *); -#line 476 - CError_ASSERT(obj->otype == OT_OBJECT); + CError_ASSERT(476, obj->otype == OT_OBJECT); arg->data.mem.obj = obj; arg->data.mem.offset = 0; arg->arg = 1; @@ -450,8 +438,7 @@ PCode *vformatpcode(short opcode, va_list argList) { break; case 'd': -#line 490 - CError_ASSERT(format[1] == '('); + CError_ASSERT(490, format[1] == '('); effect = EffectRead; format += 2; if (*format == '=') { @@ -462,8 +449,7 @@ PCode *vformatpcode(short opcode, va_list argList) { format++; } -#line 502 - CError_ASSERT(format[0] == 'b'); + CError_ASSERT(502, format[0] == 'b'); tmp = va_arg(argList, int); if (tmp == 0) @@ -477,8 +463,7 @@ PCode *vformatpcode(short opcode, va_list argList) { case 'm': obj = va_arg(argList, Object *); if (obj) { -#line 515 - CError_ASSERT(obj->otype == OT_OBJECT); + CError_ASSERT(515, obj->otype == OT_OBJECT); if (obj->datatype == DABSOLUTE) { arg->kind = PCOp_IMMEDIATE; @@ -490,7 +475,7 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->data.mem.offset = va_arg(argList, SInt32); if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4 | fPCodeFlag20000 | fPCodeFlag40000)) { - pcode->_18 = make_alias(obj, arg->data.mem.offset, nbytes_loaded_or_stored_by(pcode)); + pcode->alias = make_alias(obj, arg->data.mem.offset, nbytes_loaded_or_stored_by(pcode)); if (is_volatile_object(obj)) pcode->flags |= fIsVolatile; //if ((obj->type->type == TYPEPOINTER || obj->type->type == TYPEARRAY) ? (TYPE_POINTER(obj->type)->qual & Q_CONST) : (obj->qual & Q_CONST)) @@ -498,10 +483,9 @@ PCode *vformatpcode(short opcode, va_list argList) { pcode->flags |= fIsConst; } else { if (pcode->op == PC_ADDI) - pcode->_18 = make_alias(obj, arg->data.mem.offset, 1); + pcode->alias = make_alias(obj, arg->data.mem.offset, 1); } -#line 536 - CError_ASSERT(obj->datatype == DLOCAL || arg->data.mem.offset == 0); + CError_ASSERT(536, obj->datatype == DLOCAL || arg->data.mem.offset == 0); if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) { //if ((obj->type->type == TYPEPOINTER || obj->type->type == TYPEARRAY) ? (TYPE_POINTER(obj->type)->qual & Q_VOLATILE) : (obj->qual & Q_VOLATILE)) if (OBJ_GET_TARGET_VOLATILE(obj)) @@ -534,8 +518,7 @@ PCode *vformatpcode(short opcode, va_list argList) { case 'M': obj = va_arg(argList, Object *); if (obj) { -#line 578 - CError_ASSERT(obj->otype == OT_OBJECT); + CError_ASSERT(578, obj->otype == OT_OBJECT); if (obj->datatype == DABSOLUTE) { arg->kind = PCOp_IMMEDIATE; @@ -546,8 +529,7 @@ PCode *vformatpcode(short opcode, va_list argList) { arg->data.mem.obj = obj; arg->data.mem.offset = va_arg(argList, SInt32); -#line 590 - CError_ASSERT(obj->datatype == DLOCAL || arg->data.mem.offset == 0); + CError_ASSERT(590, obj->datatype == DLOCAL || arg->data.mem.offset == 0); if (pcode->flags & (fPCodeFlag2 | fPCodeFlag4)) { //if ((obj->type->type == TYPEPOINTER || obj->type->type == TYPEARRAY) ? (TYPE_POINTER(obj->type)->qual & Q_VOLATILE) : (obj->qual & Q_VOLATILE)) if (OBJ_GET_TARGET_VOLATILE(obj)) @@ -581,8 +563,7 @@ PCode *vformatpcode(short opcode, va_list argList) { break; default: -#line 629 - CError_FATAL(); + CError_FATAL(629); } while (format[1] && strchr("/<>|*", format[1])) { @@ -595,14 +576,13 @@ PCode *vformatpcode(short opcode, va_list argList) { case '*': case '|': case '>': - if (format[1] == 'p') { + if (format[1] == 'p') format++; - } else if (isdigit(format[1])) { + else if (isdigit(format[1])) format += pcode_const_from_format(format + 1, &thing4); - } else { -#line 659 - CError_FATAL(); - } + else + CError_FATAL(659); + break; } } @@ -736,10 +716,8 @@ int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, in buf += tmp; } name = CMangler_GetLinkName(operand->data.mem.obj)->name; - if (strlen(name) == 0 || strlen(name) > 3200 || name[0] < 0) { -#line 849 - CError_FATAL(); - } + if (strlen(name) == 0 || strlen(name) > 3200 || name[0] < 0) + CError_FATAL(849); if (strlen(name) > 50) tmp = sprintf(buf, "%45.45s...", name); else @@ -911,32 +889,26 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { buf += expectandformatoperand(pa, PCOp_REGISTER, RegClass_CRFIELD, -1, buf); break; case 'X': -#line 1124 - CError_ASSERT(pa->data.reg.reg == 0); + CError_ASSERT(1124, pa->data.reg.reg == 0); buf += expectandformatoperand(pa, PCOp_REGISTER, RegClass_SPR, -1, buf); break; case 'C': -#line 1129 - CError_ASSERT(pa->data.reg.reg == 2); + CError_ASSERT(1129, pa->data.reg.reg == 2); buf += expectandformatoperand(pa, PCOp_REGISTER, RegClass_SPR, -1, buf); break; case 'L': -#line 1134 - CError_ASSERT(pa->data.reg.reg == 1); + CError_ASSERT(1134, pa->data.reg.reg == 1); buf += expectandformatoperand(pa, PCOp_REGISTER, RegClass_SPR, -1, buf); break; case 'Z': -#line 1139 - CError_ASSERT(pa->data.reg.reg == 0); + CError_ASSERT(1139, pa->data.reg.reg == 0); buf += expectandformatoperand(pa, PCOp_REGISTER, RegClass_SPR, -1, buf); break; case 'P': - if (isdigit(format[1])) { + if (isdigit(format[1])) format += pcode_const_from_format(format + 1, &thing); - } else { -#line 1149 - CError_FATAL(); - } + else + CError_FATAL(1149); case 'S': case 'T': case 's': @@ -945,8 +917,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { } else { for (i = 0; i < 4; i++) { if (pa->data.reg.reg == spr_to_sysreg[i]) { -#line 1161 - CError_FATAL(); + CError_FATAL(1161); break; } } @@ -1002,8 +973,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { format++; tmp = *format; } else { -#line 1227 - CError_FATAL(); + CError_FATAL(1227); } } if ((tmp2 = isdigit(format[1]))) @@ -1046,14 +1016,12 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { buf += expectandformatoperand(pa + 1, PCOp_MEMORY, 0, -1, buf); else buf += expectandformatoperand(pa + 1, PCOp_IMMEDIATE, 0, -1, buf); -#line 1283 - CError_ASSERT(format[1] == '('); + CError_ASSERT(1283, format[1] == '('); format++; *(buf++) = *(format++); if (*format == '+') format++; -#line 1291 - CError_ASSERT(format[0] == 'b'); + CError_ASSERT(1291, format[0] == 'b'); if (pa->kind == PCOp_REGISTER && pa->arg == RegClass_GPR && pa->data.reg.reg == 0) { if (pa->data.reg.effect & (EffectRead | EffectWrite)) { pclist_bad_operand = 1; @@ -1088,8 +1056,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { case 'M': if (pa->kind == PCOp_MEMORY) { -#line 1335 - CError_ASSERT(pa->arg == RefType_8 || pa->arg == RefType_B || pa->arg == RefType_C); + CError_ASSERT(1335, pa->arg == RefType_8 || pa->arg == RefType_B || pa->arg == RefType_C); buf += expectandformatoperand(pa, PCOp_MEMORY, 0, -1, buf); } else if (pa->kind == PCOp_LABELDIFF) buf += expectandformatoperand(pa, PCOp_LABELDIFF, 0, -1, buf); @@ -1107,8 +1074,7 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { break; default: -#line 1465 - CError_FATAL(); + CError_FATAL(1465); } while (format[1] && strchr("/<>|*", format[1])) { @@ -1121,14 +1087,13 @@ void formatoperands(PCode *pcode, char *buf, int showBasicBlocks) { case '*': case '|': case '>': - if (format[1] == 'p') { + if (format[1] == 'p') format++; - } else if (isdigit(format[1])) { + else if (isdigit(format[1])) format += pcode_const_from_format(format + 1, &thing4); - } else { -#line 1495 - CError_FATAL(); - } + else + CError_FATAL(1495); + break; } } @@ -1286,13 +1251,11 @@ int nbytes_loaded_or_stored_by(PCode *pcode) { return 16; default: -#line 2011 - CError_FATAL(); + CError_FATAL(2011); } } -#line 2014 - CError_FATAL(); + CError_FATAL(2014); return 0; } |