mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Revise head-of-file comment.
Eliminate some excess whitespace. Fix bug in CallArgsDescriptor::get() handling call through a null pointer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16012 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ad4ce52618
commit
ac9edd5faa
@ -7,18 +7,12 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// Representation of the sequence of machine instructions created for a single
|
// Container for the sequence of MachineInstrs created for a single
|
||||||
// VM instruction. Additionally records information about hidden and implicit
|
// LLVM Instruction. MachineCodeForInstruction also tracks temporary values
|
||||||
// values used by the machine instructions: about hidden values used by the
|
// (TmpInstruction objects) created during SparcV9 code generation, so that
|
||||||
// machine instructions:
|
// they can be deleted when they are no longer needed, and finally, it also
|
||||||
//
|
// holds some extra information for 'call' Instructions (using the
|
||||||
// "Temporary values" are intermediate values used in the machine instruction
|
// CallArgsDescriptor object, which is also implemented in this file).
|
||||||
// sequence, but not in the VM instruction. Note that such values should be
|
|
||||||
// treated as pure SSA values with no interpretation of their operands (i.e., as
|
|
||||||
// a TmpInstruction object which actually represents such a value).
|
|
||||||
//
|
|
||||||
// (2) "Implicit uses" are values used in the VM instruction but not in the
|
|
||||||
// machine instruction sequence
|
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
@ -31,25 +25,24 @@
|
|||||||
#include "MachineFunctionInfo.h"
|
#include "MachineFunctionInfo.h"
|
||||||
#include "MachineInstrAnnot.h"
|
#include "MachineInstrAnnot.h"
|
||||||
#include "SparcV9TmpInstr.h"
|
#include "SparcV9TmpInstr.h"
|
||||||
|
#include "SparcV9RegisterInfo.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
|
MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
|
||||||
MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
|
MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
|
||||||
return MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries[I];
|
return MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries[I];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineCodeForInstruction::destroy(const Instruction *I) {
|
void MachineCodeForInstruction::destroy(const Instruction *I) {
|
||||||
MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
|
MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
|
||||||
MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries.erase(I);
|
MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries.erase(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void MachineCodeForInstruction::dropAllReferences() {
|
||||||
MachineCodeForInstruction::dropAllReferences()
|
|
||||||
{
|
|
||||||
for (unsigned i=0, N=tempVec.size(); i < N; i++)
|
for (unsigned i=0, N=tempVec.size(); i < N; i++)
|
||||||
cast<Instruction>(tempVec[i])->dropAllReferences();
|
cast<Instruction>(tempVec[i])->dropAllReferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MachineCodeForInstruction::~MachineCodeForInstruction() {
|
MachineCodeForInstruction::~MachineCodeForInstruction() {
|
||||||
// Let go of all uses in temp. instructions
|
// Let go of all uses in temp. instructions
|
||||||
dropAllReferences();
|
dropAllReferences();
|
||||||
@ -65,7 +58,6 @@ MachineCodeForInstruction::~MachineCodeForInstruction() {
|
|||||||
delete callArgsDesc;
|
delete callArgsDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CallArgsDescriptor::CallArgsDescriptor(CallInst* _callInstr,
|
CallArgsDescriptor::CallArgsDescriptor(CallInst* _callInstr,
|
||||||
TmpInstruction* _retAddrReg,
|
TmpInstruction* _retAddrReg,
|
||||||
bool _isVarArgs, bool _noPrototype)
|
bool _isVarArgs, bool _noPrototype)
|
||||||
@ -91,21 +83,26 @@ CallInst *CallArgsDescriptor::getReturnValue() const {
|
|||||||
return (callInstr->getType() == Type::VoidTy? NULL : callInstr);
|
return (callInstr->getType() == Type::VoidTy? NULL : callInstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mechanism to get the descriptor for a CALL MachineInstr.
|
/// CallArgsDescriptor::get - Mechanism to get the descriptor for a CALL
|
||||||
// We get the LLVM CallInstr from the ret. addr. register argument
|
/// MachineInstr. We get the LLVM CallInst from the return-address register
|
||||||
// of the CALL MachineInstr (which is explicit operand #3 for indirect
|
/// argument of the CALL MachineInstr (which is explicit operand #2 for
|
||||||
// calls or the last implicit operand for direct calls). We then get
|
/// indirect calls or the last implicit operand for direct calls). We then get
|
||||||
// the CallArgsDescriptor from the MachineCodeForInstruction object for
|
/// the CallArgsDescriptor from the MachineCodeForInstruction object for the
|
||||||
// the CallInstr.
|
/// CallInstr. This is roundabout but avoids adding a new map or annotation
|
||||||
// This is roundabout but avoids adding a new map or annotation just
|
/// just to keep track of CallArgsDescriptors.
|
||||||
// to keep track of CallArgsDescriptors.
|
///
|
||||||
//
|
CallArgsDescriptor *CallArgsDescriptor::get(const MachineInstr *MI) {
|
||||||
CallArgsDescriptor *CallArgsDescriptor::get(const MachineInstr* MI) {
|
const Value *retAddrVal = 0;
|
||||||
const TmpInstruction* retAddrReg =
|
if ((MI->getOperand (0).getType () == MachineOperand::MO_MachineRegister
|
||||||
cast<TmpInstruction>(isa<Function>(MI->getOperand(0).getVRegValue())
|
&& MI->getOperand (0).getReg () == SparcV9::g0)
|
||||||
? MI->getImplicitRef(MI->getNumImplicitRefs()-1)
|
|| (MI->getOperand (0).getType () == MachineOperand::MO_VirtualRegister
|
||||||
: MI->getOperand(2).getVRegValue());
|
&& !isa<Function> (MI->getOperand (0).getVRegValue ()))) {
|
||||||
|
retAddrVal = MI->getOperand (2).getVRegValue ();
|
||||||
|
} else {
|
||||||
|
retAddrVal = MI->getImplicitRef (MI->getNumImplicitRefs () - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const TmpInstruction* retAddrReg = cast<TmpInstruction> (retAddrVal);
|
||||||
assert(retAddrReg->getNumOperands() == 1 &&
|
assert(retAddrReg->getNumOperands() == 1 &&
|
||||||
isa<CallInst>(retAddrReg->getOperand(0)) &&
|
isa<CallInst>(retAddrReg->getOperand(0)) &&
|
||||||
"Location of callInstr arg for CALL instr. changed? FIX THIS CODE!");
|
"Location of callInstr arg for CALL instr. changed? FIX THIS CODE!");
|
||||||
|
Loading…
Reference in New Issue
Block a user