1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-05-17 16:03:24 -07:00

add branch-likely pseudo-instructions

This commit is contained in:
Connor Olding 2016-04-07 07:56:46 -07:00
parent da1c49cbfb
commit 356aee5e9f
2 changed files with 36 additions and 17 deletions

View File

@ -371,17 +371,19 @@ data.instructions = {
-- pseudo-instructions -- pseudo-instructions
B = {4, 'r', '00o'}, -- BEQ R0, R0, offset B = { 4, 'r', '00o'}, -- BEQ R0, R0, offset
BAL = {1, 'r', '0Co', 17}, -- BGEZAL R0, offset BAL = { 1, 'r', '0Co', 17}, -- BGEZAL R0, offset
BEQZ = {4, 'sr', 's0o'}, -- BEQ RS, R0, offset BEQZ = { 4, 'sr', 's0o'}, -- BEQ RS, R0, offset
BNEZ = {5, 'sr', 's0o'}, -- BNE RS, R0, offset BEQZL = {20, 'sr', 's0o'}, -- BEQL RS, R0, offset
CL = {0, 'd', '00d0C', 37}, -- OR RD, R0, R0 BNEZ = { 5, 'sr', 's0o'}, -- BNE RS, R0, offset
MOV = {0, 'ds', 's0d0C', 37}, -- OR RD, RS, R0 BNEZL = {21, 'sr', 's0o'}, -- BNEL RS, R0, offset
NEG = {0, 'dt', '0td0C', 34}, -- SUB RD, R0, RT CL = { 0, 'd', '00d0C', 37}, -- OR RD, R0, R0
NOP = {0, '', '0'}, -- SLL R0, R0, 0 MOV = { 0, 'ds', 's0d0C', 37}, -- OR RD, RS, R0
NOT = {0, 'ds', 's0d0C', 39}, -- NOR RD, RS, R0 NEG = { 0, 'dt', '0td0C', 34}, -- SUB RD, R0, RT
SUBI = {8, 'tsk', 'sti'}, -- ADDI RT, RS, -immediate NOP = { 0, '', '0'}, -- SLL R0, R0, 0
SUBIU = {9, 'tsk', 'sti'}, -- ADDIU RT, RS, -immediate NOT = { 0, 'ds', 's0d0C', 39}, -- NOR RD, RS, R0
SUBI = { 8, 'tsk', 'sti'}, -- ADDI RT, RS, -immediate
SUBIU = { 9, 'tsk', 'sti'}, -- ADDIU RT, RS, -immediate
-- ...that expand to multiple instructions -- ...that expand to multiple instructions
LI = __, -- only one instruction for values < 0x10000 LI = __, -- only one instruction for values < 0x10000
@ -409,12 +411,17 @@ data.instructions = {
SLE = __, SLEI = __, SLEIU = __, SLEU = __, SLE = __, SLEI = __, SLEIU = __, SLEU = __,
SNE = __, SNEI = __, SNEIU = __, SNEU = __, SNE = __, SNEI = __, SNEIU = __, SNEU = __,
BEQI = __, BGE = __,
BNEI = __, BLE = __,
BGE = __, BGEI = __, BLT = __,
BLE = __, BLEI = __, BGT = __,
BLT = __, BLTI = __,
BGT = __, BGTI = __, BEQI = __, BEQIL = __,
BNEI = __, BNEIL = __,
BGEI = __, BGEIL = __,
BLEI = __, BLEIL = __,
BLTI = __, BLTIL = __,
BGTI = __, BGTIL = __,
} }
data.all_instructions = {} data.all_instructions = {}

View File

@ -237,6 +237,12 @@ local branch_basics = {
BLEI = "BNE", BLEI = "BNE",
BLTI = "BNE", BLTI = "BNE",
BNEI = "BNE", BNEI = "BNE",
BEQIL = "BEQL",
BGEIL = "BEQL",
BGTIL = "BEQL",
BLEIL = "BNEL",
BLTIL = "BNEL",
BNEIL = "BNEL",
} }
function overrides.BEQI(self, name) function overrides.BEQI(self, name)
@ -261,6 +267,8 @@ function overrides.BEQI(self, name)
self:format_out(branch, args) self:format_out(branch, args)
end end
overrides.BNEI = overrides.BEQI overrides.BNEI = overrides.BEQI
overrides.BEQIL = overrides.BEQI
overrides.BNEIL = overrides.BEQI
function overrides.BLTI(self, name) function overrides.BLTI(self, name)
local slti = instructions['SLTI'] local slti = instructions['SLTI']
@ -284,6 +292,8 @@ function overrides.BLTI(self, name)
self:format_out(branch, args) self:format_out(branch, args)
end end
overrides.BGEI = overrides.BLTI overrides.BGEI = overrides.BLTI
overrides.BLTIL = overrides.BLTI
overrides.BGEIL = overrides.BLTI
function overrides.BLEI(self, name) function overrides.BLEI(self, name)
-- TODO: this can probably be optimized -- TODO: this can probably be optimized
@ -323,5 +333,7 @@ function overrides.BLEI(self, name)
self:format_out(branch, args) self:format_out(branch, args)
end end
overrides.BGTI = overrides.BLEI overrides.BGTI = overrides.BLEI
overrides.BLEIL = overrides.BLEI
overrides.BGTIL = overrides.BLEI
return overrides return overrides