aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2013-09-29 16:30:26 +0200
committerDrahflow <drahflow@gmx.de>2013-09-29 16:30:26 +0200
commit0e4db45b56b6f384b251dd64ede92f928fd16422 (patch)
treed36cb267a669b545755440d1b3802b4d85f68225
parent077e49c56ab827be2fedfc2cc40934c387f69222 (diff)
Slight cleanups...
-rw-r--r--elymas/lib/sys/opt.ey33
1 files changed, 15 insertions, 18 deletions
diff --git a/elymas/lib/sys/opt.ey b/elymas/lib/sys/opt.ey
index 8ac7980..bd1f9ae 100644
--- a/elymas/lib/sys/opt.ey
+++ b/elymas/lib/sys/opt.ey
@@ -227,11 +227,16 @@
mode 16 div 1 band {
[ STATICDOT offsetInScope parentCount inExtensionArea ] i 1 sub logic =[]
- mode 1 band { # TODO bail out for activation mode of 2
- [ CALL "*" | +rawCodeAddress ] i logic =[]
- } {
- [ NOP ] i logic =[]
- } ? *
+ [
+ { mode 0 eq }' {
+ [ NOP ] i logic =[]
+ } { mode 1 eq }' {
+ [ CALL "*" | +rawCodeAddress ] i logic =[]
+ } { 1 }' {
+ # TODO this might conceivably be legal though...
+ "static . resolution resulted in execution mode neither 0 nor 1" die
+ }
+ ] conds
} { } ? *
} {
relevantScope dump
@@ -456,9 +461,13 @@
0 /rsp :pushqMemDisp8
] ] =entry
}
+ { action CALL streq { 1 entry * "--" | +rawCodeAddress eq }' andif }' {
+ [ NATIVE [
+ 8 /rsp :addqImm8Reg
+ ] ] =entry
+ }
{ action CALL streq { 1 entry * "-" | +rawCodeAddress eq }' andif { 0 last * PUSH streq }' andif }' {
1 last * +rawObject ==constant
- #"Rewriting constant -" dump constant dump
{ -1010 lt -012 ? } /max deffd
@@ -472,17 +481,12 @@
[ /rax /rcx /rdx /rbx /rbp /rsi /rdi ] =*:availableRegisters
- #"starUsed: " dump starUsed dump
- #"largestNumber: " dump starUsed dump
-
starUsed {
# TODO maybe implement this one day
} {
largestNumber |availableRegisters len gt {
# TODO maybe implement this one day
} {
- #"Rewriting implemented" dump
-
[ NATIVE [
0 largestNumber 1 add range {
availableRegisters :popqReg
@@ -507,11 +511,8 @@
sys .opt "::" via
o +rawAddress ==addr
- # "Addr: " dump addr dump
[ addr _ 4 add range peek each ] 256 math .unbase ==totalLength
[ addr 8 add _ 4 add range peek each ] 256 math .unbase ==codeLength
- # "Total length: " dump totalLength dump
- # "Code length: " dump codeLength dump
addr 16 add ==i
{ =*ops =*set =*get ==pattern
@@ -661,7 +662,6 @@
# [ :ud2 ] emitOpcodes # enable for further development
isScoping {
- # "scoping function" dump
[
8 /r15 :subqImm8Reg
/r15 :popqMem
@@ -674,7 +674,6 @@
/rax /r14 :movqRegReg
] emitOpcodes
}" {
- # "unscoping function" dump
[
8 /r15 :subqImm8Reg
/r15 :popqMem
@@ -865,8 +864,6 @@
] emitOpcodes
}' ? *
- # "optimization finished" dump
-
newReferences newOpcodes o ::replace
1 executingScope # return something different from o to signal successful optimization
} /optimize deffd