summaryrefslogtreecommitdiff
path: root/chapter21/src/main/java/com/seaofnodes
diff options
context:
space:
mode:
Diffstat (limited to 'chapter21/src/main/java/com/seaofnodes')
-rw-r--r--chapter21/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/NewX86.java17
1 files changed, 3 insertions, 14 deletions
diff --git a/chapter21/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/NewX86.java b/chapter21/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/NewX86.java
index a87074f4..e751fa23 100644
--- a/chapter21/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/NewX86.java
+++ b/chapter21/src/main/java/com/seaofnodes/simple/node/cpus/x86_64_v2/NewX86.java
@@ -6,33 +6,22 @@ import com.seaofnodes.simple.node.*;
import com.seaofnodes.simple.type.TypeFunPtr;
public class NewX86 extends NewNode implements MachNode {
- public static final String OS = System.getProperty("os.name");
- public static final RegMask ARG2 = OS.startsWith("Windows")
- ? x86_64_v2.callWin64(TypeFunPtr.CALLOC,2)
- : x86_64_v2.callSys5 (TypeFunPtr.CALLOC,2);
- public static final RegMask ARG3 = OS.startsWith("Windows")
- ? x86_64_v2.callWin64(TypeFunPtr.CALLOC,3)
- : x86_64_v2.callSys5 (TypeFunPtr.CALLOC,3);
-
// A pre-zeroed chunk of memory.
NewX86( NewNode nnn ) { super(nnn); }
@Override public String op() { return "alloc"; }
// Size and pointer result in standard calling convention; null for all the
// memory aliases edges
- @Override public RegMask regmap(int i) { return i==1 ? ARG2 : null; }
+ @Override public RegMask regmap(int i) { return i==1 ? x86_64_v2.callInMask(TypeFunPtr.CALLOC,2) : null; }
@Override public RegMask outregmap(int i) { return i == 1 ? x86_64_v2.RAX_MASK : null; }
@Override public RegMask outregmap() { return null; }
- @Override public RegMask killmap() {
- return OS.startsWith("Windows")
- ? x86_64_v2. WIN64_CALLER_SAVE_MASK
- : x86_64_v2.SYSTEM5_CALLER_SAVE_MASK;
- }
+ @Override public RegMask killmap() { return x86_64_v2.x86CallerSave(); }
@Override public void encoding( Encoding enc ) {
enc.external(this,"calloc");
// This has to call the *native* ABI, regardless of how Simple is
// being compiled, because it links against the native calloc.
// ldi rcx,#1 // number of elements to calloc
+ RegMask ARG3 = x86_64_v2.callInMask(TypeFunPtr.CALLOC,3);
enc.add1(0xB8 + ARG3.firstReg()).add4(1);
// E8 cd CALL rel32;
enc.add1(0xE8);