Browse Source

lib/load-asm: greatly improve loading time with less strings

master
Lephenixnoir 11 months ago
parent
commit
ca1217af1b
Signed by: Lephenixnoir GPG Key ID: 1BBA026E13FC0495
  1. 13
      lib/load-asm.l

13
lib/load-asm.l

@ -173,19 +173,22 @@ static Pattern make_pattern(char const *code)
Returns a semantic FxOS::Argument. */
static Argument make_arg(int token, int opsize, int m, int n, int d, int i)
{
/* TODO: This function is too slow for the ~100k times it is called. */
using Reg = CpuRegister;
static Reg general_purpose[16] = {
Reg::R0, Reg::R1, Reg::R2, Reg::R3, Reg::R4, Reg::R5,
Reg::R6, Reg::R7, Reg::R8, Reg::R9, Reg::R10, Reg::R11,
Reg::R12, Reg::R13, Reg::R14, Reg::R15,
};
/* Registers rn and rm */
CpuRegister Rn(format("r%d", n & 0xf));
CpuRegister Rm(format("r%d", m & 0xf));
CpuRegister Rn = general_purpose[n & 0xf];
CpuRegister Rm = general_purpose[m & 0xf];
/* Sign extensions of d to 8 and 12 bits */
int32_t d8 = (int8_t)d;
int32_t d12 = (d & 0x800) ? (int32_t)(d | 0xfffff000) : (d);
/* Sign extension of i to 8 bits */
int32_t i8 = (int8_t)i;
using Reg = CpuRegister;
switch(token)
{
case R0: return Argument_Reg(Reg::R0);

Loading…
Cancel
Save