1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-05-03 18:13:23 -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
B = {4, 'r', '00o'}, -- BEQ R0, R0, offset
BAL = {1, 'r', '0Co', 17}, -- BGEZAL R0, offset
BEQZ = {4, 'sr', 's0o'}, -- BEQ RS, R0, offset
BNEZ = {5, 'sr', 's0o'}, -- BNE RS, R0, offset
CL = {0, 'd', '00d0C', 37}, -- OR RD, R0, R0
MOV = {0, 'ds', 's0d0C', 37}, -- OR RD, RS, R0
NEG = {0, 'dt', '0td0C', 34}, -- SUB RD, R0, RT
NOP = {0, '', '0'}, -- SLL R0, R0, 0
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
B = { 4, 'r', '00o'}, -- BEQ R0, R0, offset
BAL = { 1, 'r', '0Co', 17}, -- BGEZAL R0, offset
BEQZ = { 4, 'sr', 's0o'}, -- BEQ RS, R0, offset
BEQZL = {20, 'sr', 's0o'}, -- BEQL RS, R0, offset
BNEZ = { 5, 'sr', 's0o'}, -- BNE RS, R0, offset
BNEZL = {21, 'sr', 's0o'}, -- BNEL RS, R0, offset
CL = { 0, 'd', '00d0C', 37}, -- OR RD, R0, R0
MOV = { 0, 'ds', 's0d0C', 37}, -- OR RD, RS, R0
NEG = { 0, 'dt', '0td0C', 34}, -- SUB RD, R0, RT
NOP = { 0, '', '0'}, -- SLL R0, R0, 0
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
LI = __, -- only one instruction for values < 0x10000
@ -409,12 +411,17 @@ data.instructions = {
SLE = __, SLEI = __, SLEIU = __, SLEU = __,
SNE = __, SNEI = __, SNEIU = __, SNEU = __,
BEQI = __,
BNEI = __,
BGE = __, BGEI = __,
BLE = __, BLEI = __,
BLT = __, BLTI = __,
BGT = __, BGTI = __,
BGE = __,
BLE = __,
BLT = __,
BGT = __,
BEQI = __, BEQIL = __,
BNEI = __, BNEIL = __,
BGEI = __, BGEIL = __,
BLEI = __, BLEIL = __,
BLTI = __, BLTIL = __,
BGTI = __, BGTIL = __,
}
data.all_instructions = {}

View File

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