From: Shane B. <br...@cs...> - 2004-03-01 07:45:18
|
I'm looking to retrive a value out of an OPT_RegisterOperand object. Here's the corresponding source code.... --------------------------------------------------------------------------------- //Create a Register to hold the tib OPT_RegisterOperand THE_TIB = ir.regpool.makeTemp(VM_TypeReference.Address); //Create a Register to hold the type which will be fetched from the tib OPT_RegisterOperand THE_TYPE = ir.regpool.makeTemp(VM_TypeReference.VM_Type); // Create instruction to get the tib OPT_Instruction getTibInstruction = Unary.create(GET_OBJ_TIB, THE_TIB, THIS_POINTER); // Create instruction to get type from tib OPT_Instruction getTypeInstruction = Unary.create(GET_TYPE_FROM_TIB, THE_TYPE, THE_TIB); // Create a counter instruction and insert it before the call site // NOTE: THE_TYPE.toString() currently doesn't give the type of the object OPT_Instruction counterInst = data.getCounterInstructionForEvent(callSiteTriple.toString() + " " + THE_TYPE.toString()); // Now insert the instructions before the call site to obtain the needed data instr.insertBefore(getTibInstruction); instr.insertBefore(getTypeInstruction); instr.insertBefore(counterInst); --------------------------------------------------------------------------------- Basically I'm writing an optimization phase that attempts to grab the runtime type of the reciever object at a call site. The first 2 instructions should get the TIB and the object type and store it in the corresponding OPT_RegisterOperand objects. However I'm not sure how to get the value (the runtime type) out of the OPT_RegisterOperand object and then cast it to a string. I know I can create an instruction that can call my own function which can take the OPT_RegisterOperand as a parameter, but I've read there can be an overhead with this and I figure there must be an easier way to do this. Anybody have an idea of how to do this? -- Shane A. Brewer M.Sc. Student of Computing Science University Of Alberta Edmonton, Alberta, Canada Email - br...@cs... Website - http://www.cs.ualberta.ca/~brewer |