mirror of
https://github.com/notwa/lips
synced 2024-11-14 09:09:02 -08:00
add basic branch pseudos, add REG(REG) addressing
This commit is contained in:
parent
03eb1b9ed5
commit
b596405e76
1 changed files with 43 additions and 0 deletions
|
@ -13,6 +13,12 @@ local function tob_override(self, name)
|
|||
if self:peek('DEREF') then
|
||||
offset = 0
|
||||
base = self:pop('DEREF')
|
||||
elseif self:peek('REG') then
|
||||
local o = self:pop('CPU')
|
||||
local b = self:pop('DEREF'):set('tt', 'REG')
|
||||
self:push_new('ADDU', 'AT', o, b)
|
||||
offset = 0
|
||||
base = self:token('DEREF', 'AT')
|
||||
else -- NUM or LABELSYM
|
||||
local o = self:pop('CONST')
|
||||
if self:peek('NUM') then
|
||||
|
@ -213,6 +219,43 @@ local branch_basics = {
|
|||
BNEIL = 'BNEL',
|
||||
}
|
||||
|
||||
function overrides:BLT(name)
|
||||
local slt = name:sub(#name) == 'U' and 'SLTU' or 'SLT'
|
||||
local a = self:pop('CPU')
|
||||
local b = self:pop('CPU')
|
||||
local offset = self:pop('CONST')
|
||||
self:push_new(slt, 'AT', a, b)
|
||||
self:push_new('BNEZ', 'AT', offset)
|
||||
end
|
||||
function overrides:BGE(name)
|
||||
local slt = name:sub(#name) == 'U' and 'SLTU' or 'SLT'
|
||||
local a = self:pop('CPU')
|
||||
local b = self:pop('CPU')
|
||||
local offset = self:pop('CONST')
|
||||
self:push_new(slt, 'AT', a, b)
|
||||
self:push_new('BEQZ', 'AT', offset)
|
||||
end
|
||||
function overrides:BLE(name)
|
||||
local slt = name:sub(#name) == 'U' and 'SLTU' or 'SLT'
|
||||
local a = self:pop('CPU')
|
||||
local b = self:pop('CPU')
|
||||
local offset = self:pop('CONST')
|
||||
self:push_new(slt, 'AT', b, a)
|
||||
self:push_new('BEQZ', 'AT', offset)
|
||||
end
|
||||
function overrides:BGT(name)
|
||||
local slt = name:sub(#name) == 'U' and 'SLTU' or 'SLT'
|
||||
local a = self:pop('CPU')
|
||||
local b = self:pop('CPU')
|
||||
local offset = self:pop('CONST')
|
||||
self:push_new(slt, 'AT', b, a)
|
||||
self:push_new('BNEZ', 'AT', offset)
|
||||
end
|
||||
overrides.BLTU = overrides.BLT
|
||||
overrides.BGEU = overrides.BGE
|
||||
overrides.BLEU = overrides.BLE
|
||||
overrides.BGTU = overrides.BGT
|
||||
|
||||
function overrides:BEQI(name)
|
||||
local branch = branch_basics[name]
|
||||
local reg = self:pop('CPU')
|
||||
|
|
Loading…
Reference in a new issue