1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-04-30 00:53:23 -07:00

add basic branch pseudos, add REG(REG) addressing

This commit is contained in:
Connor Olding 2016-05-01 00:56:15 -07:00
parent 03eb1b9ed5
commit b596405e76

View File

@ -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')