use of org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand in project JikesRVM by JikesRVM.
the class ClassLoaderProxy method getLongFromConstantPool.
public static LongConstantOperand getLongFromConstantPool(RVMClass klass, int index) {
Offset offset = klass.getLiteralOffset(index);
long val = Statics.getSlotContentsAsLong(offset);
return new LongConstantOperand(val);
}
use of org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand in project JikesRVM by JikesRVM.
the class MinimalBURS method buildTree.
// //////////////////////////////
// Implementation
// //////////////////////////////
/**
* Build a BURS Tree for each Instruction.
* Complete BURS trees by adding leaf nodes as needed, and
* creating tree edges by calling insertChild1() or insertChild2()
* This step is also where we introduce intermediate tree nodes for
* any LIR instruction that has > 2 "real" operands e.g., a CALL.
*
* @param s The instruction for which a tree must be built
* @return the root of the newly constructed tree
*/
private AbstractBURS_TreeNode buildTree(Instruction s) {
AbstractBURS_TreeNode root = AbstractBURS_TreeNode.create(new DepGraphNode(s));
AbstractBURS_TreeNode cur = root;
for (Enumeration<Operand> uses = s.getUses(); uses.hasMoreElements(); ) {
Operand op = uses.nextElement();
if (op == null)
continue;
// Set child = AbstractBURS_TreeNode for operand op
AbstractBURS_TreeNode child;
if (op instanceof RegisterOperand) {
if (op.asRegister().getRegister().isValidation())
continue;
child = Register;
} else if (op instanceof IntConstantOperand) {
child = new BURS_IntConstantTreeNode(((IntConstantOperand) op).value);
} else if (op instanceof LongConstantOperand) {
child = LongConstant;
} else if (op instanceof AddressConstantOperand) {
child = AddressConstant;
} else if (op instanceof BranchOperand && s.isCall()) {
child = BranchTarget;
} else if (op instanceof InlinedOsrTypeInfoOperand && s.isYieldPoint()) {
child = NullTreeNode;
} else {
continue;
}
// Attach child as child of cur_parent in correct position
if (cur.child1 == null) {
cur.child1 = child;
} else if (cur.child2 == null) {
cur.child2 = child;
} else {
// Create auxiliary node so as to represent
// a instruction with arity > 2 in a binary tree.
AbstractBURS_TreeNode child1 = cur.child2;
AbstractBURS_TreeNode aux = AbstractBURS_TreeNode.create(OTHER_OPERAND_opcode);
cur.child2 = aux;
cur = aux;
cur.child1 = child1;
cur.child2 = child;
}
}
// patch for calls & return
switch(s.getOpcode()) {
case CALL_opcode:
case SYSCALL_opcode:
case YIELDPOINT_OSR_opcode:
if (cur.child2 == null) {
cur.child2 = NullTreeNode;
}
// fall through
case RETURN_opcode:
if (cur.child1 == null) {
cur.child1 = NullTreeNode;
}
}
return root;
}
use of org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand in project JikesRVM by JikesRVM.
the class BURS_Helpers method ATTEMPT_LONG.
/**
* This routine expands an ATTEMPT instruction into an atomic
* compare exchange. The atomic compare and exchange will place at
* mo the value of newValue if the value of mo is oldValue. The
* result register is set to 0/1 depending on whether the valye was
* replaced or not.
*
* @param result the register operand that is set to 0/1 as a result
* of the attempt
* @param mo the address at which to attempt the exchange
* @param oldValue the old value to check for at the address mo
* @param newValue the new value to place at the address mo
*/
protected final void ATTEMPT_LONG(RegisterOperand result, MemoryOperand mo, Operand oldValue, Operand newValue) {
if (VM.BuildFor32Addr) {
// Set up EDX:EAX with the old value
if (oldValue.isRegister()) {
Register oldValue_hval = oldValue.asRegister().getRegister();
Register oldValue_lval = regpool.getSecondReg(oldValue_hval);
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEDX(), TypeReference.Int), new RegisterOperand(oldValue_hval, TypeReference.Int)));
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEAX(), TypeReference.Int), new RegisterOperand(oldValue_lval, TypeReference.Int)));
} else {
if (VM.VerifyAssertions)
opt_assert(oldValue.isLongConstant());
LongConstantOperand val = oldValue.asLongConstant();
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEDX(), TypeReference.Int), IC(val.upper32())));
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEAX(), TypeReference.Int), IC(val.lower32())));
}
// Set up ECX:EBX with the new value
if (newValue.isRegister()) {
Register newValue_hval = newValue.asRegister().getRegister();
Register newValue_lval = regpool.getSecondReg(newValue_hval);
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getECX(), TypeReference.Int), new RegisterOperand(newValue_hval, TypeReference.Int)));
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEBX(), TypeReference.Int), new RegisterOperand(newValue_lval, TypeReference.Int)));
} else {
if (VM.VerifyAssertions)
opt_assert(newValue.isLongConstant());
LongConstantOperand val = newValue.asLongConstant();
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getECX(), TypeReference.Int), IC(val.upper32())));
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEBX(), TypeReference.Int), IC(val.lower32())));
}
EMIT(MIR_CompareExchange8B.create(IA32_LOCK_CMPXCHG8B, new RegisterOperand(getEDX(), TypeReference.Int), new RegisterOperand(getEAX(), TypeReference.Int), mo, new RegisterOperand(getECX(), TypeReference.Int), new RegisterOperand(getEBX(), TypeReference.Int)));
RegisterOperand temp = regpool.makeTemp(result);
EMIT(MIR_Set.create(IA32_SET__B, temp, IA32ConditionOperand.EQ()));
// need to zero-extend the result of the set
EMIT(MIR_Unary.create(IA32_MOVZX__B, result, temp.copy()));
} else {
RegisterOperand temp = regpool.makeTempLong();
RegisterOperand temp2 = regpool.makeTemp(result);
EMIT(MIR_Move.create(IA32_MOV, temp, newValue));
EMIT(MIR_Move.create(IA32_MOV, new RegisterOperand(getEAX(), TypeReference.Long), oldValue));
EMIT(MIR_CompareExchange.create(IA32_LOCK_CMPXCHG, new RegisterOperand(getEAX(), TypeReference.Long), mo, temp.copyRO()));
EMIT(MIR_Set.create(IA32_SET__B, temp2, IA32ConditionOperand.EQ()));
// need to zero-extend the result of the set
EMIT(MIR_Unary.create(IA32_MOVZX__B, result, temp2.copy()));
}
}
use of org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand in project JikesRVM by JikesRVM.
the class BURS_Helpers method LONG_CMP.
/**
* Expansion of LONG_CMP: compare to values and set result to -1, 0, 1 for <, =, >,
* respectively
*
* @param s the compare instruction
* @param res the result/first operand
* @param val1 the first value
* @param val2 the second value
*/
protected final void LONG_CMP(Instruction s, RegisterOperand res, Operand val1, Operand val2) {
if (VM.BuildFor32Addr) {
RegisterOperand one = regpool.makeTempInt();
RegisterOperand lone = regpool.makeTempInt();
Operand two, ltwo;
if (val1 instanceof RegisterOperand) {
Register val1_reg = val1.asRegister().getRegister();
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, one, new RegisterOperand(val1_reg, TypeReference.Int))));
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, lone, new RegisterOperand(regpool.getSecondReg(val1_reg), TypeReference.Int))));
} else {
LongConstantOperand tmp = (LongConstantOperand) val1;
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, one, IC(tmp.upper32()))));
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, lone, IC(tmp.lower32()))));
}
if (val2 instanceof RegisterOperand) {
two = val2;
ltwo = L(burs.ir.regpool.getSecondReg(val2.asRegister().getRegister()));
} else {
LongConstantOperand tmp = (LongConstantOperand) val2;
two = IC(tmp.upper32());
ltwo = IC(tmp.lower32());
}
EMIT(CPOS(s, MIR_Compare.create(IA32_CMP, lone.copyRO(), ltwo)));
EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_SBB, one.copyRO(), two)));
EMIT(CPOS(s, MIR_Set.create(IA32_SET__B, res, // res =
IA32ConditionOperand.LT())));
// (val1 < val2) ? 1 :0
EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_OR, one.copyRO(), lone.copyRO())));
EMIT(CPOS(s, MIR_Set.create(IA32_SET__B, lone.copyRO(), // lone = (val1 != val2) ? 1 : 0
IA32ConditionOperand.NE())));
// res = (val1 <
EMIT(CPOS(s, MIR_UnaryAcc.create(IA32_NEG, res.copyRO())));
// val2) ? -1 :0
EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_OR, res.copyRO(), lone.copyRO())));
EMIT(MIR_Unary.mutate(s, IA32_MOVSX__B, res.copyRO(), res.copyRO()));
} else {
RegisterOperand one = regpool.makeTempLong();
RegisterOperand two = regpool.makeTempLong();
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, one, val1)));
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, two, val2)));
EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_SUB, one, two)));
EMIT(CPOS(s, MIR_Set.create(IA32_SET__B, res, IA32ConditionOperand.NE())));
EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_SAR, one.copyRO(), LC(64))));
EMIT(CPOS(s, MIR_BinaryAcc.create(IA32_OR, res.copyRO(), one.copyRO())));
}
}
use of org.jikesrvm.compilers.opt.ir.operand.LongConstantOperand in project JikesRVM by JikesRVM.
the class BURS_Helpers method SSE2_GPR2FPR_64.
/**
* Emits code to move 64 bits from GPRs to SSE2 FPRs
*
* @param s instruction to modify for the move
*/
protected final void SSE2_GPR2FPR_64(Instruction s) {
int offset = -burs.ir.stackManager.allocateSpaceForConversion();
StackLocationOperand sl = new StackLocationOperand(true, offset, QW);
Operand val = Unary.getClearVal(s);
if (VM.BuildFor32Addr) {
StackLocationOperand sl1 = new StackLocationOperand(true, offset + 4, DW);
StackLocationOperand sl2 = new StackLocationOperand(true, offset, DW);
Operand i1, i2;
if (val instanceof RegisterOperand) {
RegisterOperand rval = (RegisterOperand) val;
i1 = val;
i2 = new RegisterOperand(regpool.getSecondReg(rval.getRegister()), TypeReference.Int);
} else {
LongConstantOperand rhs = (LongConstantOperand) val;
i1 = IC(rhs.upper32());
i2 = IC(rhs.lower32());
}
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, sl1, i1)));
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, sl2, i2)));
EMIT(MIR_Move.mutate(s, IA32_MOVSD, Unary.getResult(s), sl));
} else {
EMIT(CPOS(s, MIR_Move.create(IA32_MOV, sl, val)));
EMIT(MIR_Move.mutate(s, IA32_MOVSD, Unary.getResult(s), sl.copy()));
}
}
Aggregations