add support for branch comparisons using the TST instruction

... and bump vale to pull in the recent commit that adds support for them.
This will be needed for repeated enclave entry/return.
This commit is contained in:
Andrew Baumann 2017-03-21 22:26:18 -07:00
Родитель 2add290f70
Коммит a22ce80aa8
4 изменённых файлов: 21 добавлений и 4 удалений

@ -1 +1 @@
Subproject commit 22ce0745df01ac11661b54ad28e1b063beb32e6d
Subproject commit b5f9c87e71d2af6b87a486bbb221b5f393186b30

Просмотреть файл

@ -252,7 +252,7 @@ datatype ins =
//-----------------------------------------------------------------------------
// Code Representation
//-----------------------------------------------------------------------------
datatype ocmp = OEq | ONe | OLe | OGe | OLt | OGt
datatype ocmp = OEq | ONe | OLe | OGe | OLt | OGt | OTstEq | OTstNe
datatype obool = OCmp(cmp:ocmp, o1:operand, o2:operand)
datatype codes = CNil | va_CCons(hd:code, tl:codes)
@ -833,6 +833,8 @@ function evalCmp(c:ocmp, i1:word, i2:word):bool
case OGe => i1 >= i2
case OLt => i1 < i2
case OGt => i1 > i2
case OTstEq => BitwiseAnd(i1, i2) == 0
case OTstNe => BitwiseAnd(i1, i2) != 0
}
function evalOBool(s:state, o:obool):bool

Просмотреть файл

@ -34,6 +34,8 @@ function method cmpNot(c:ocmp):ocmp
case OGe => OLt
case OLt => OGe
case OGt => OLe
case OTstEq => OTstNe
case OTstNe => OTstEq
}
method printBcc(c:ocmp)
@ -45,6 +47,17 @@ method printBcc(c:ocmp)
case OGe => print(" BGE ");
case OLt => print(" BLT ");
case OGt => print(" BGT ");
case OTstEq => print(" BEQ ");
case OTstNe => print(" BNE ");
}
method printCmp(c:ocmp, o1:operand, o2:operand)
{
if c == OTstEq || c == OTstNe {
printIns2Op("TST", o1, o2);
} else {
printIns2Op("CMP", o1, o2);
}
}
/*
@ -276,7 +289,7 @@ method printCode(c:code, n:int) returns(n':int)
var false_branch := n;
var end_of_block := n + 1;
// Do comparison
printIns2Op("CMP", ifb.o1, ifb.o2);
printCmp(ifb.cmp, ifb.o1, ifb.o2);
// Branch to false branch if cond is false
printBcc(cmpNot(ifb.cmp)); printLabel(false_branch); nl();
// True branch
@ -297,7 +310,7 @@ method printCode(c:code, n:int) returns(n':int)
printLabel(n1); print(":"); nl();
n' := printCode(loop, n + 2);
printLabel(n2); print(":"); nl();
printIns2Op("CMP", b.o1, b.o2);
printCmp(b.cmp, b.o1, b.o2);
printBcc(b.cmp); printLabel(n1); nl();
}
}

Просмотреть файл

@ -65,6 +65,8 @@ function method va_cmp_le(o1:operand, o2:operand):obool { OCmp(OLe, o1, o2) }
function method va_cmp_ge(o1:operand, o2:operand):obool { OCmp(OGe, o1, o2) }
function method va_cmp_lt(o1:operand, o2:operand):obool { OCmp(OLt, o1, o2) }
function method va_cmp_gt(o1:operand, o2:operand):obool { OCmp(OGt, o1, o2) }
function method va_cmp_tst_eq(o1:operand, o2:operand):obool { OCmp(OTstEq, o1, o2) }
function method va_cmp_tst_ne(o1:operand, o2:operand):obool { OCmp(OTstNe, o1, o2) }
function method va_Block(block:codes):code { Block(block) }
function method va_IfElse(ifb:obool, ift:code, iff:code):code { IfElse(ifb, ift, iff) }