mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Create new accessors to get arguments for call/invoke instructions. It breaks
encapsulation to force the users of these classes to know about the internal data structure of the Operands structure. It also can lead to errors, like in the MSIL writer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105539 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6c8099243a
commit
22a5b29820
@ -940,6 +940,9 @@ public:
|
|||||||
/// Provide fast operand accessors
|
/// Provide fast operand accessors
|
||||||
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
||||||
|
|
||||||
|
unsigned getNumArgOperands() const { return getNumOperands() - 1; }
|
||||||
|
Value *getArgOperand(unsigned i) const { return getOperand(i + 1); }
|
||||||
|
|
||||||
/// getCallingConv/setCallingConv - Get or set the calling convention of this
|
/// getCallingConv/setCallingConv - Get or set the calling convention of this
|
||||||
/// function call.
|
/// function call.
|
||||||
CallingConv::ID getCallingConv() const {
|
CallingConv::ID getCallingConv() const {
|
||||||
@ -2432,6 +2435,9 @@ public:
|
|||||||
/// Provide fast operand accessors
|
/// Provide fast operand accessors
|
||||||
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
|
||||||
|
|
||||||
|
unsigned getNumArgOperands() const { return getNumOperands() - 3; }
|
||||||
|
Value *getArgOperand(unsigned i) const { return getOperand(i); }
|
||||||
|
|
||||||
/// getCallingConv/setCallingConv - Get or set the calling convention of this
|
/// getCallingConv/setCallingConv - Get or set the calling convention of this
|
||||||
/// function call.
|
/// function call.
|
||||||
CallingConv::ID getCallingConv() const {
|
CallingConv::ID getCallingConv() const {
|
||||||
|
@ -252,13 +252,13 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V,
|
|||||||
} else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
|
} else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
|
||||||
// Make sure that this is just the function being called, not that it is
|
// Make sure that this is just the function being called, not that it is
|
||||||
// passing into the function.
|
// passing into the function.
|
||||||
for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = CI->getNumArgOperands(); i != e; ++i)
|
||||||
if (CI->getOperand(i) == V) return true;
|
if (CI->getArgOperand(i) == V) return true;
|
||||||
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
|
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
|
||||||
// Make sure that this is just the function being called, not that it is
|
// Make sure that this is just the function being called, not that it is
|
||||||
// passing into the function.
|
// passing into the function.
|
||||||
for (unsigned i = 0, e = II->getNumOperands() - 3; i != e; ++i)
|
for (unsigned i = 0, e = II->getNumArgOperands(); i != e; ++i)
|
||||||
if (II->getOperand(i) == V) return true;
|
if (II->getArgOperand(i) == V) return true;
|
||||||
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(*UI)) {
|
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(*UI)) {
|
||||||
if (CE->getOpcode() == Instruction::GetElementPtr ||
|
if (CE->getOpcode() == Instruction::GetElementPtr ||
|
||||||
CE->getOpcode() == Instruction::BitCast) {
|
CE->getOpcode() == Instruction::BitCast) {
|
||||||
|
@ -1150,16 +1150,18 @@ namespace {
|
|||||||
const InvokeInst* inv = cast<InvokeInst>(I);
|
const InvokeInst* inv = cast<InvokeInst>(I);
|
||||||
Out << "std::vector<Value*> " << iName << "_params;";
|
Out << "std::vector<Value*> " << iName << "_params;";
|
||||||
nl(Out);
|
nl(Out);
|
||||||
for (unsigned i = 0; i < inv->getNumOperands() - 3; ++i) {
|
for (unsigned i = 0; i < inv->getNumArgOperands(); ++i) {
|
||||||
Out << iName << "_params.push_back("
|
Out << iName << "_params.push_back("
|
||||||
<< opNames[i] << ");";
|
<< getOpName(inv->getArgOperand(i)) << ");";
|
||||||
nl(Out);
|
nl(Out);
|
||||||
}
|
}
|
||||||
|
// FIXME: This shouldn't use magic numbers -3, -2, and -1.
|
||||||
Out << "InvokeInst *" << iName << " = InvokeInst::Create("
|
Out << "InvokeInst *" << iName << " = InvokeInst::Create("
|
||||||
<< opNames[Ops - 3] << ", "
|
<< getOpName(inv->getCalledFunction()) << ", "
|
||||||
<< opNames[Ops - 2] << ", "
|
<< getOpName(inv->getNormalDest()) << ", "
|
||||||
<< opNames[Ops - 1] << ", "
|
<< getOpName(inv->getUnwindDest()) << ", "
|
||||||
<< iName << "_params.begin(), " << iName << "_params.end(), \"";
|
<< iName << "_params.begin(), "
|
||||||
|
<< iName << "_params.end(), \"";
|
||||||
printEscapedString(inv->getName());
|
printEscapedString(inv->getName());
|
||||||
Out << "\", " << bbname << ");";
|
Out << "\", " << bbname << ");";
|
||||||
nl(Out) << iName << "->setCallingConv(";
|
nl(Out) << iName << "->setCallingConv(";
|
||||||
|
@ -845,10 +845,11 @@ void MSILWriter::printCallInstruction(const Instruction* Inst) {
|
|||||||
// Handle intrinsic function.
|
// Handle intrinsic function.
|
||||||
printIntrinsicCall(cast<IntrinsicInst>(Inst));
|
printIntrinsicCall(cast<IntrinsicInst>(Inst));
|
||||||
} else {
|
} else {
|
||||||
|
const CallInst *CI = cast<CallInst>(Inst);
|
||||||
// Load arguments to stack and call function.
|
// Load arguments to stack and call function.
|
||||||
for (int I = 1, E = Inst->getNumOperands(); I!=E; ++I)
|
for (int I = 0, E = CI->getNumArgOperands(); I!=E; ++I)
|
||||||
printValueLoad(Inst->getOperand(I));
|
printValueLoad(CI->getArgOperand(I));
|
||||||
printFunctionCall(Inst->getOperand(0),Inst);
|
printFunctionCall(CI->getCalledFunction(), Inst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,8 +1003,8 @@ void MSILWriter::printInvokeInstruction(const InvokeInst* Inst) {
|
|||||||
std::string Label = "leave$normal_"+utostr(getUniqID());
|
std::string Label = "leave$normal_"+utostr(getUniqID());
|
||||||
Out << ".try {\n";
|
Out << ".try {\n";
|
||||||
// Load arguments
|
// Load arguments
|
||||||
for (int I = 3, E = Inst->getNumOperands(); I!=E; ++I)
|
for (int I = 0, E = Inst->getNumArgOperands(); I!=E; ++I)
|
||||||
printValueLoad(Inst->getOperand(I));
|
printValueLoad(Inst->getArgOperand(I));
|
||||||
// Print call instruction
|
// Print call instruction
|
||||||
printFunctionCall(Inst->getOperand(0),Inst);
|
printFunctionCall(Inst->getOperand(0),Inst);
|
||||||
// Save function result and leave "try" block
|
// Save function result and leave "try" block
|
||||||
|
Loading…
Reference in New Issue
Block a user