comparison modules/x86.tp @ 363:d949fe826e04

Unify il and backend labels
author Michael Pavone <pavone@retrodev.com>
date Sat, 25 Apr 2015 20:56:02 -0700
parents 7101ad443081
children e44f65abaf0e
comparison
equal deleted inserted replaced
362:7101ad443081 363:d949fe826e04
464 shiftRot: shift dst size withOpEx: 1u8 464 shiftRot: shift dst size withOpEx: 1u8
465 } 465 }
466 466
467 ret <- { inst: [ 0xC3u8 ] } 467 ret <- { inst: [ 0xC3u8 ] }
468 468
469 label <- { 469 label <- { il label }
470 _offset <- -1
471 _forwardRefs <- #[]
472 #{
473 length <- { 0 }
474 hasOffset? <- { _offset >= 0 }
475 offset <- { _offset }
476 isInteger? <- { false }
477 register? <- { false }
478 label? <- { true }
479 flattenTo:at <- :dest :idx {
480 if: (not: hasOffset?) {
481 _offset <- idx
482 foreach: _forwardRefs :idx fun {
483 fun: _offset
484 }
485 _forwardRefs <- #[]
486 }
487 idx
488 }
489 string <- { "label: " . _offset }
490 withOffset:else <- :fun :elsefun {
491 if: hasOffset? {
492 fun: _offset
493 } else: {
494 _forwardRefs append: fun
495 elsefun:
496 }
497 }
498 }
499 }
500 470
501 jmp <- :jmpDest { 471 jmp <- :jmpDest {
502 if: (jmpDest label?) { 472 if: (jmpDest label?) {
503 _size <- -1 473 _size <- -1
504 #{ 474 #{
885 outarr append: (ret: ) 855 outarr append: (ret: )
886 } 856 }
887 { 857 {
888 //skipIf 858 //skipIf
889 endlab <- label: 859 endlab <- label:
890 outarr append: (jcc: (mapcond: (inst cond)) endlab) 860 outarr append: (jcc: (mapcond: (inst cond)) (endlab reference))
891 foreach: (inst toskip) :_ inst { 861 foreach: (inst toskip) :_ inst {
892 convertIL: inst to: outarr withLabels: labels withSaved: saved 862 convertIL: inst to: outarr withLabels: labels withSaved: saved
893 } 863 }
894 outarr append: endlab 864 outarr append: endlab
895 } 865 }
896 //skipIf:else 866 //skipIf:else
897 { 867 {
898 endlab <- label: 868 endlab <- label:
899 elselab <- label: 869 elselab <- label:
900 outarr append: (jcc: (mapcond: (inst cond)) elselab) 870 outarr append: (jcc: (mapcond: (inst cond)) (elselab reference))
901 foreach: (inst toskip) :_ inst { 871 foreach: (inst toskip) :_ inst {
902 convertIL: inst to: outarr withLabels: labels withSaved: saved 872 convertIL: inst to: outarr withLabels: labels withSaved: saved
903 } 873 }
904 outarr append: (jmp: endlab) 874 outarr append: (jmp: (endlab reference))
905 outarr append: elselab 875 outarr append: elselab
906 foreach: (inst else) :_ inst { 876 foreach: (inst else) :_ inst {
907 convertIL: inst to: outarr withLabels: labels withSaved: saved 877 convertIL: inst to: outarr withLabels: labels withSaved: saved
908 } 878 }
909 outarr append: endlab 879 outarr append: endlab
928 { 898 {
929 outarr append: (setcc: (mapcond: (inst cond)) (inst out)) 899 outarr append: (setcc: (mapcond: (inst cond)) (inst out))
930 } 900 }
931 //label 901 //label
932 { 902 {
903 outarr append: inst
933 } 904 }
934 //data 905 //data
935 { 906 {
936 outarr append: (data: (inst bytes)) 907 outarr append: (data: (inst bytes))
937 } 908 }