mirror of
https://github.com/notwa/lips
synced 2024-11-14 18:09:03 -08:00
optimize LI/LA
This commit is contained in:
parent
89fcdd825d
commit
32368f3998
1 changed files with 8 additions and 3 deletions
11
lips.lua
11
lips.lua
|
@ -917,19 +917,24 @@ function Parser:instruction()
|
||||||
args.rt = self:register()
|
args.rt = self:register()
|
||||||
self:optional_comma()
|
self:optional_comma()
|
||||||
local im = self:const()
|
local im = self:const()
|
||||||
|
|
||||||
local is_label = im[1] == 'LABELSYM'
|
local is_label = im[1] == 'LABELSYM'
|
||||||
|
-- this is really just semantics as far as i can tell
|
||||||
if h == 'LI' and is_label then
|
if h == 'LI' and is_label then
|
||||||
self:error('use LA for labels')
|
self:error('use LA for labels')
|
||||||
end
|
end
|
||||||
if h == 'LA' and not is_label then
|
if h == 'LA' and not is_label then
|
||||||
self:error('use LI for immediates')
|
self:error('use LI for immediates')
|
||||||
end
|
end
|
||||||
if h == 'LA' or im[2] >= 0x10000 then
|
|
||||||
|
if im[2] >= 0x10000 then
|
||||||
args.rs = args.rt
|
args.rs = args.rt
|
||||||
args.immediate = {'UPPER', im}
|
args.immediate = {'UPPER', im}
|
||||||
self:format_out(lui[3], lui[1], args, lui[4], lui[5])
|
self:format_out(lui[3], lui[1], args, lui[4], lui[5])
|
||||||
args.immediate = {'LOWER', im}
|
if im[2] % 0x10000 ~= 0 then
|
||||||
self:format_out(ori[3], ori[1], args, ori[4], ori[5])
|
args.immediate = {'LOWER', im}
|
||||||
|
self:format_out(ori[3], ori[1], args, ori[4], ori[5])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
args.rs = 'R0'
|
args.rs = 'R0'
|
||||||
args.immediate = {'LOWER', im}
|
args.immediate = {'LOWER', im}
|
||||||
|
|
Loading…
Reference in a new issue