Skip to content

Commit be77c8c

Browse files
committed
CogVM source as per VMMaker.oscog-eem.3708
Simplify the high bit implementation in advance of implementing instantiating 64-bit large integer results on 32-bit platforms (itself a precursor for integrating Hernán's live typing work). Add XorCq:R:. On IA32 use the same computeSizeOfArithCqR/ concretizeArithCqRWithRO:eaxOpcode: scheme for CqR ops as X64 in computeMaximumSize/dispatchConcretize.
1 parent 67270d8 commit be77c8c

File tree

24 files changed

+914
-1374
lines changed

24 files changed

+914
-1374
lines changed

src/spur32.cog.lowcode/cogit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Automatically generated by
2-
CCodeGenerator VMMaker.oscog-eem.3703 uuid: 85364028-fc2e-4da5-88f8-910243509f86
3-
(Cog-eem.504, Compiler-eem.526)
2+
CCodeGenerator VMMaker.oscog-eem.3708 uuid: d1d43de6-5ba0-4455-beb1-9453dc974144
3+
(Cog-eem.507, Compiler-eem.527)
44
*/
55

66

src/spur32.cog.lowcode/cogitARMv5.c

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* Automatically generated by
2-
CCodeGenerator VMMaker.oscog-eem.3703 uuid: 85364028-fc2e-4da5-88f8-910243509f86
3-
(Cog-eem.504, Compiler-eem.526)
2+
CCodeGenerator VMMaker.oscog-eem.3707 uuid: 3a1e2973-7850-4efc-b8a6-1e64764914a4
3+
(Cog-eem.507, * Compiler-eem.526)
44
from
5-
StackToRegisterMappingCogit VMMaker.oscog-eem.3703 uuid: 85364028-fc2e-4da5-88f8-910243509f86
5+
StackToRegisterMappingCogit VMMaker.oscog-eem.3707 uuid: 3a1e2973-7850-4efc-b8a6-1e64764914a4
66
*/
7-
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3703 uuid: 85364028-fc2e-4da5-88f8-910243509f86 " __DATE__ ;
7+
static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3707 uuid: 3a1e2973-7850-4efc-b8a6-1e64764914a4 " __DATE__ ;
88
char *__cogitBuildInfo = __buildInfo;
99

1010

@@ -19510,13 +19510,12 @@ genPrimitiveGreaterThan(void)
1951019510
}
1951119511

1951219512

19513-
/* Implementation notes: there are two reasons to use TempReg
19514-
-1) if primitive fails, ReceiverResultReg must remain unchanged (we
19515-
CompletePrimitive) -2) CLZ/BSR only work on 64bits for registers R0-R7 on
19516-
Intel X64. But Win64 uses R9
19517-
Normally, this should be backEnd dependent, but for now we have a single
19518-
64bits target...
19519-
*/
19513+
/* Defer to the backEnd to generate the best instruction sequence.
19514+
Some backends have an efficient count-leading-zeros that must
19515+
be inverted to produce the high bit, others have a genuine high
19516+
bit. Intel has both, the former only in newer revisions.
19517+
Use TempReg. If primitive fails, ReceiverResultReg must remain
19518+
unchanged (we CompletePrimitive) */
1952019519

1952119520
/* CogObjectRepresentation>>#genPrimitiveHighBit */
1952219521
static sqInt
@@ -19525,40 +19524,30 @@ genPrimitiveHighBit(void)
1952519524
AbstractInstruction *anInstruction;
1952619525
AbstractInstruction *jumpNegativeReceiver;
1952719526

19527+
/* begin CmpCq:R: */
19528+
/* begin gen:quickConstant:operand: */
19529+
anInstruction = genoperandoperand(CmpCqR, 0, ReceiverResultReg);
19530+
if (usesOutOfLineLiteral(anInstruction)) {
19531+
(anInstruction->dependent = locateLiteral(0));
19532+
}
19533+
jumpNegativeReceiver = genConditionalBranchoperand(JumpLess, ((sqInt)0));
1952819534

1952919535
/* remove excess tag bits from the receiver oop */
19530-
/* and use the abstract cogit facility for case of single tag-bit */
1953119536
backEnd;
1953219537

19533-
/* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */
19534-
/* begin genHighBitClzIn:ofSmallIntegerOopWithSingleTagBit: */
19538+
/* begin genHighBitOfNonZeroReg:into: */
19539+
1953519540
/* ClzR:R: */
1953619541
genoperandoperand(ClzRR, ReceiverResultReg, TempReg);
19537-
if (!(setsConditionCodesFor(lastOpcode(), JumpZero))) {
19538-
/* begin CmpCq:R: */
19539-
/* begin gen:quickConstant:operand: */
19540-
anInstruction = genoperandoperand(CmpCqR, 0, TempReg);
19541-
if (usesOutOfLineLiteral(anInstruction)) {
19542-
(anInstruction->dependent = locateLiteral(0));
19543-
}
19544-
}
19545-
jumpNegativeReceiver = genConditionalBranchoperand(JumpZero, ((sqInt)0));
1954619542

19547-
/* Note the nice bit trick below:
19543+
/* Invert leading zeroas into highBit.
19544+
Note the nice bit trick below:
1954819545
highBit_1based_of_small_int_value = (BytesPerWord * 8) - leadingZeroCout_of_oop - 1 toAccountForTagBit.
1954919546
This is like 2 complements (- reg - 1) on (BytesPerWord * 8) log2 bits, or exactly a bit invert operation... */
1955019547

19551-
/* #XorCw:R: #gen:literal:operand: */
19552-
checkLiteralforInstruction((BytesPerWord * 8) - 1, genoperandoperand(XorCwR, (BytesPerWord * 8) - 1, TempReg));
19553-
19554-
/* Jump is NULL if above operation is not implemented, else return the result */
19555-
if (!jumpNegativeReceiver) {
19556-
return UnimplementedPrimitive;
19557-
}
19558-
19559-
/* MoveR:R: */
19560-
genoperandoperand(MoveRR, TempReg, ReceiverResultReg);
19561-
genConvertIntegerToSmallIntegerInReg(ReceiverResultReg);
19548+
/* #XorCq:R: #gen:literal:operand: */
19549+
checkLiteralforInstruction((BytesPerWord * 8) - 1, genoperandoperand(XorCqR, (BytesPerWord * 8) - 1, TempReg));
19550+
genConvertIntegerInRegtoSmallIntegerInReg(TempReg, ReceiverResultReg);
1956219551

1956319552
/* genPrimReturn */
1956419553
if (methodOrBlockNumArgs <= (numRegArgs())) {

0 commit comments

Comments
 (0)