diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-01-10 11:05:21 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-01-10 11:05:21 +0000 |
commit | aec1b8dddc68ecb8288ec6132932e4c7b4bca09f (patch) | |
tree | 8138328fe43bcc5fff690dc60caac79aa570ab2b /compiler_and_linker/unsorted/InlineAsmPPC.c | |
parent | fcfbafff31869ed808bff0639532db1828660e92 (diff) | |
download | MWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.tar.gz MWCC-aec1b8dddc68ecb8288ec6132932e4c7b4bca09f.zip |
getting close to done
Diffstat (limited to 'compiler_and_linker/unsorted/InlineAsmPPC.c')
-rw-r--r-- | compiler_and_linker/unsorted/InlineAsmPPC.c | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/compiler_and_linker/unsorted/InlineAsmPPC.c b/compiler_and_linker/unsorted/InlineAsmPPC.c index 19c8fdc..e3a5f98 100644 --- a/compiler_and_linker/unsorted/InlineAsmPPC.c +++ b/compiler_and_linker/unsorted/InlineAsmPPC.c @@ -1,32 +1,29 @@ #include "compiler/InlineAsmPPC.h" #include "compiler/CError.h" +#include "compiler/CExpr.h" #include "compiler/CInt64.h" #include "compiler/CFunc.h" #include "compiler/CMachine.h" #include "compiler/CParser.h" #include "compiler/CPrep.h" #include "compiler/CPrepTokenizer.h" -#include "compiler/TOC.h" +#include "compiler/Alias.h" +#include "compiler/CodeGen.h" +#include "compiler/CodeGenOptPPC.h" +#include "compiler/CompilerTools.h" +#include "compiler/Exceptions.h" #include "compiler/FuncLevelAsmPPC.h" #include "compiler/InlineAsm.h" #include "compiler/InlineAsmMnemonicsPPC.h" #include "compiler/InlineAsmRegisters.h" #include "compiler/InlineAsmRegistersPPC.h" -#include "compiler/CodeGen.h" -#include "compiler/CodeGenOptPPC.h" -#include "compiler/PPCError.h" -#include "compiler/RegisterInfo.h" -#include "compiler/objects.h" -#include "compiler/CExpr.h" #include "compiler/PCode.h" #include "compiler/PCodeUtilities.h" +#include "compiler/PPCError.h" +#include "compiler/RegisterInfo.h" #include "compiler/StackFrame.h" -#include "compiler/CompilerTools.h" -#include "compiler/Alias.h" - -// TODO: move me -extern int countexceptionactionregisters(ExceptionAction *); -extern void noteexceptionactionregisters(ExceptionAction *, PCodeArg *); +#include "compiler/TOC.h" +#include "compiler/objects.h" char asm_alloc_flags[10]; Section sm_section; @@ -35,17 +32,12 @@ SInt32 fralloc_parameter_area_size; Boolean user_responsible_for_frame; Boolean supports_hardware_fpu; UInt32 assembledinstructions; -UInt8 assembler_type; +AssemblerType assembler_type; char volatileasm; Boolean InlineAsm_gccmode; Boolean InlineAsm_labelref; CLabel *pic_base_label; -enum { - NO_REG = 0, - INVALID_PIC_REG = -2 -}; - // forward decls static SInt32 InlineAsm_ConstantExpressionPPC(SInt32 value); static Object *isvariableoperand(void); @@ -71,8 +63,9 @@ static void IllegalObjectOperator(HashNameNode *name1, HashNameNode *name2, shor case TK_SHR: opstr = ">>"; break; case '<': opstr = "<"; break; case '>': opstr = ">"; break; - case TK_LESS_EQUAL: opstr = "<="; break; - case TK_GREATER_EQUAL: opstr = ">="; break; + // bug? these two seem swapped + case TK_LESS_EQUAL: opstr = ">="; break; + case TK_GREATER_EQUAL: opstr = "<="; break; case TK_LOGICAL_EQ: opstr = "=="; break; case TK_LOGICAL_NE: opstr = "!="; break; case '&': opstr = "&"; break; @@ -1478,7 +1471,7 @@ static int mnemonic_has_overflow(char *buf) { return result; } -static int mnemonic_has_absolute(char *buf) { +static int mnemonic_has_absolute(const char *buf) { int result = 0; char last = buf[strlen(buf) - 1]; @@ -1488,7 +1481,7 @@ static int mnemonic_has_absolute(char *buf) { return result; } -static int mnemonic_has_linkregister(char *buf) { +static int mnemonic_has_linkregister(const char *buf) { int result = 0; char last = buf[strlen(buf) - 1]; @@ -1552,7 +1545,7 @@ void InlineAsm_InitializePPC(void) { cpu |= 0x40000000; } -void InlineAsm_Initialize(UInt8 assemblertype) { +void InlineAsm_Initialize(AssemblerType assemblertype) { assembler_type = assemblertype; if (assembler_type == 0) { @@ -1608,7 +1601,7 @@ static InlineAsm *InlineAsm_CreateFrFree(void) { return ia; } -SInt32 InlineAsm_IsDirective(UInt8 assemblertype) { +SInt32 InlineAsm_IsDirective(AssemblerType assemblertype) { char *name; SInt32 directive = IADirective_Null; @@ -1619,7 +1612,7 @@ SInt32 InlineAsm_IsDirective(UInt8 assemblertype) { name = tkidentifier->name; if (!strcmp(name, "machine")) { directive = IADirective_Machine; - } else if (assemblertype == 1) { + } else if (assemblertype == AssemblerType_1) { if (!strcmp(name, "entry")) { directive = IADirective_Entry; } else if (!strcmp(name, "fralloc")) { @@ -1815,6 +1808,7 @@ void InlineAsm_ScanAssemblyInstruction(void) { Boolean flag1; Boolean flag2; SInt32 directive; + OpcodeInfo *info; char buf[20]; flag1 = 0; @@ -1837,9 +1831,10 @@ void InlineAsm_ScanAssemblyInstruction(void) { if (!mnemonic) CError_Error(CErrorStr261); - flag3 = (FLAG_SET_F(opcodeinfo[mnemonic->x4].flags) & fPCodeFlag4000000) && (mnemonic->x10 & 0x400); - flag4 = (FLAG_SET_T(opcodeinfo[mnemonic->x4].flags) & fPCodeFlag20000000) && (mnemonic->x10 & 2); - flag5 = (FLAG_SET_T(opcodeinfo[mnemonic->x4].flags) & fPCodeFlag2000000) && (mnemonic->x10 & 1); + info = &opcodeinfo[mnemonic->x4]; + flag3 = (FLAG_SET_F(info->flags) & fPCodeFlag4000000) && (mnemonic->x10 & 0x400); + flag4 = (FLAG_SET_T(info->flags) & fPCodeFlag20000000) && (mnemonic->x10 & 2); + flag5 = (FLAG_SET_T(info->flags) & fPCodeFlag2000000) && (mnemonic->x10 & 1); if ((cpu == CPUMask_Generic) && (cpu & CPUFLAG_LOW_MASK) != ((cpu & mnemonic->cpu) & CPUFLAG_LOW_MASK)) { CError_Error(CErrorStr152); @@ -1901,8 +1896,7 @@ void InlineAsm_ScanAssemblyInstruction(void) { ++assembledinstructions; } -static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, UInt8 assemblertype) { - OpcodeInfo *info; +static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, AssemblerType assemblertype) { PCode *pc; int index; int extra_args; @@ -1911,6 +1905,7 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, UInt8 SInt32 buffersize; IAOperand *src; PCodeArg *dest; + OpcodeInfo *info; info = &opcodeinfo[ia->opcode]; index = 0; @@ -2106,7 +2101,7 @@ static PCode *InlineAsm_TranslateIRtoPCodePPC(InlineAsm *ia, int argcount, UInt8 dest->kind = PCOp_REGISTER; dest->arg = RegClass_GPR; dest->data.reg.reg = i; - dest->data.reg.effect = (short) ((ia->opcode == PC_LMW) ? EffectWrite : EffectRead); + dest->data.reg.effect = ((ia->opcode == PC_LMW) ? EffectWrite : EffectRead); } } @@ -2485,8 +2480,8 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) { CError_FATAL(4087); } - CError_ASSERT(4090, effects->numoperands <= 16); - CError_ASSERT(4093, effects->numlabels <= 16); + CError_ASSERT(4090, (UInt32) effects->numoperands <= IAMaxOperands); + CError_ASSERT(4093, (UInt32) effects->numlabels <= IAMaxLabels); } for (i = 0, op = ia->args; i < ia->argcount; i++, op++) { @@ -2526,7 +2521,7 @@ void CodeGen_GetAsmEffects(Statement *stmt, IAEffects *effects) { break; } - CError_ASSERT(4151, effects->numoperands <= 16); + CError_ASSERT(4151, (UInt32) effects->numoperands <= IAMaxOperands); } if ((info->flags & (fPCodeFlag1 | fPCodeFlag8)) && (SInt32)effects->numlabels == 0) |