s/MethodType/FunctionType

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2115 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-04-04 22:19:18 +00:00
parent 3d0dceb733
commit 2aac6bf66a
10 changed files with 39 additions and 41 deletions

View File

@ -53,7 +53,7 @@ public:
// PATypeHandle - Handle to a Type subclass. This class is parameterized so
// that users can have handles to MethodType's that are still specialized, for
// that users can have handles to FunctionType's that are still specialized, for
// example. This class is a simple class used to keep the use list of abstract
// types up-to-date.
//

View File

@ -15,7 +15,7 @@
#include "llvm/BasicBlock.h"
#include "llvm/ConstantVals.h"
#include "llvm/iOther.h"
#include "llvm/Method.h"
#include "llvm/Function.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Assembly/Parser.h"
#include "Support/StringExtras.h"
@ -174,9 +174,9 @@ struct BBPlaceHolderHelper : public BasicBlock {
}
};
struct MethPlaceHolderHelper : public Method {
MethPlaceHolderHelper(const Type *Ty) : Method(cast<const MethodType>(Ty),
true) {}
struct MethPlaceHolderHelper : public Function {
MethPlaceHolderHelper(const Type *Ty)
: Function(cast<FunctionType>(Ty), true) {}
};
typedef PlaceholderValue<InstPlaceHolderHelper> ValuePlaceHolder;
@ -185,7 +185,7 @@ typedef PlaceholderValue<BBPlaceHolderHelper> BBPlaceHolder;
static inline ValID &getValIDFromPlaceHolder(const Value *Val) {
const Type *Ty = Val->getType();
if (isa<PointerType>(Ty) &&
isa<MethodType>(cast<PointerType>(Ty)->getElementType()))
isa<FunctionType>(cast<PointerType>(Ty)->getElementType()))
Ty = cast<PointerType>(Ty)->getElementType();
switch (Ty->getPrimitiveID()) {
@ -197,7 +197,7 @@ static inline ValID &getValIDFromPlaceHolder(const Value *Val) {
static inline int getLineNumFromPlaceHolder(const Value *Val) {
const Type *Ty = Val->getType();
if (isa<PointerType>(Ty) &&
isa<MethodType>(cast<PointerType>(Ty)->getElementType()))
isa<FunctionType>(cast<PointerType>(Ty)->getElementType()))
Ty = cast<PointerType>(Ty)->getElementType();
switch (Ty->getPrimitiveID()) {

View File

@ -230,14 +230,14 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
// Check to make sure we have a pointer to method type
PointerType *PTy = dyn_cast<PointerType>(M->getType());
if (PTy == 0) return failure(true);
MethodType *MTy = dyn_cast<MethodType>(PTy->getElementType());
FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType());
if (MTy == 0) return failure(true);
vector<Value *> Params;
const MethodType::ParamTypes &PL = MTy->getParamTypes();
const FunctionType::ParamTypes &PL = MTy->getParamTypes();
if (!MTy->isVarArg()) {
MethodType::ParamTypes::const_iterator It = PL.begin();
FunctionType::ParamTypes::const_iterator It = PL.begin();
switch (Raw.NumOperands) {
case 0: cerr << "Invalid call instruction encountered!\n";
@ -290,11 +290,11 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
// Check to make sure we have a pointer to method type
PointerType *PTy = dyn_cast<PointerType>(M->getType());
if (PTy == 0) return failure(true);
MethodType *MTy = dyn_cast<MethodType>(PTy->getElementType());
FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType());
if (MTy == 0) return failure(true);
vector<Value *> Params;
const MethodType::ParamTypes &PL = MTy->getParamTypes();
const FunctionType::ParamTypes &PL = MTy->getParamTypes();
vector<unsigned> &args = *Raw.VarArgs;
BasicBlock *Normal, *Except;
@ -305,7 +305,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
Normal = cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2));
Except = cast<BasicBlock>(getValue(Type::LabelTy, args[0]));
MethodType::ParamTypes::const_iterator It = PL.begin();
FunctionType::ParamTypes::const_iterator It = PL.begin();
for (unsigned i = 1; i < args.size(); i++) {
if (It == PL.end()) return failure(true);
// TODO: Check getValue for null!

View File

@ -226,13 +226,13 @@ void BytecodeWriter::processInstruction(const Instruction *I) {
NumOperands++;
} else if (const CallInst *CI = dyn_cast<CallInst>(I)) {// Handle VarArg calls
PointerType *Ty = cast<PointerType>(CI->getCalledValue()->getType());
if (cast<MethodType>(Ty->getElementType())->isVarArg()) {
if (cast<FunctionType>(Ty->getElementType())->isVarArg()) {
outputInstrVarArgsCall(I, Table, Type, Out);
return;
}
} else if (const InvokeInst *II = dyn_cast<InvokeInst>(I)) { // ... & Invokes
PointerType *Ty = cast<PointerType>(II->getCalledValue()->getType());
if (cast<MethodType>(Ty->getElementType())->isVarArg()) {
if (cast<FunctionType>(Ty->getElementType())->isVarArg()) {
outputInstrVarArgsCall(I, Table, Type, Out);
return;
}

View File

@ -327,9 +327,9 @@ ChooseAddInstructionByType(const Type* resultType)
MachineOpCode opCode = INVALID_OPCODE;
if (resultType->isIntegral() ||
resultType->isPointerType() ||
resultType->isLabelType() ||
isa<MethodType>(resultType) ||
isa<PointerType>(resultType) ||
isa<FunctionType>(resultType) ||
resultType == Type::LabelTy ||
resultType == Type::BoolTy)
{
opCode = ADD;

View File

@ -264,10 +264,8 @@ bool UltraSparcRegInfo::isVarArgCall(const MachineInstr *CallMI) const {
const MachineOperand & calleeOp = CallMI->getOperand(0);
Value *calleeVal = calleeOp.getVRegValue();
PointerType *PT = cast<PointerType> (calleeVal->getType());
MethodType *MT = cast<MethodType>(PT->getElementType());
return MT->isVarArg();
PointerType *PT = cast<PointerType>(calleeVal->getType());
return cast<FunctionType>(PT->getElementType())->isVarArg();
}

View File

@ -832,7 +832,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
if (OpNum == 0) {
PointerType *PTy = dyn_cast<PointerType>(Ty);
if (PTy == 0) return false; // Can't convert to a non-pointer type...
MethodType *MTy = dyn_cast<MethodType>(PTy->getElementType());
FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType());
if (MTy == 0) return false; // Can't convert to a non ptr to method...
// Perform sanity checks to make sure that new method type has the
@ -858,7 +858,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
// reason for this is that we prefer to have resolved methods but casted
// arguments if possible.
//
const MethodType::ParamTypes &PTs = MTy->getParamTypes();
const FunctionType::ParamTypes &PTs = MTy->getParamTypes();
for (unsigned i = 0, NA = PTs.size(); i < NA; ++i)
if (!PTs[i]->isLosslesslyConvertableTo(I->getOperand(i+1)->getType()))
return false; // Operands must have compatible types!
@ -871,7 +871,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
}
const PointerType *MPtr = cast<PointerType>(I->getOperand(0)->getType());
const MethodType *MTy = cast<MethodType>(MPtr->getElementType());
const FunctionType *MTy = cast<FunctionType>(MPtr->getElementType());
if (!MTy->isVarArg()) return false;
if ((OpNum-1) < MTy->getParamTypes().size())
@ -1100,8 +1100,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
if (Meth == OldVal) { // Changing the method pointer?
PointerType *NewPTy = cast<PointerType>(NewVal->getType());
MethodType *NewTy = cast<MethodType>(NewPTy->getElementType());
const MethodType::ParamTypes &PTs = NewTy->getParamTypes();
FunctionType *NewTy = cast<FunctionType>(NewPTy->getElementType());
const FunctionType::ParamTypes &PTs = NewTy->getParamTypes();
// Get an iterator to the call instruction so that we can insert casts for
// operands if needbe. Note that we do not require operands to be

View File

@ -67,8 +67,8 @@ Pass *createTraceValuesPassForBasicBlocks() { // Trace BB's and methods
//
bool InsertTraceCode::doInitialization(Module *M) {
const Type *SBP = PointerType::get(Type::SByteTy);
const MethodType *MTy =
MethodType::get(Type::IntTy, vector<const Type*>(1, SBP), true);
const FunctionType *MTy =
FunctionType::get(Type::IntTy, vector<const Type*>(1, SBP), true);
PrintfFunc = M->getOrInsertFunction("printf", MTy);
return false;

View File

@ -15,16 +15,16 @@
CallInst::CallInst(Value *Meth, const std::vector<Value*> &params,
const std::string &Name)
: Instruction(cast<MethodType>(cast<PointerType>(Meth->getType())
: Instruction(cast<FunctionType>(cast<PointerType>(Meth->getType())
->getElementType())->getReturnType(),
Instruction::Call, Name) {
Operands.reserve(1+params.size());
Operands.push_back(Use(Meth, this));
const MethodType *MTy =
cast<MethodType>(cast<PointerType>(Meth->getType())->getElementType());
const FunctionType *MTy =
cast<FunctionType>(cast<PointerType>(Meth->getType())->getElementType());
const MethodType::ParamTypes &PL = MTy->getParamTypes();
const FunctionType::ParamTypes &PL = MTy->getParamTypes();
assert((params.size() == PL.size()) ||
(MTy->isVarArg() && params.size() >= PL.size()) &&
"Calling a function with bad signature");
@ -47,17 +47,17 @@ InvokeInst::InvokeInst(Value *Meth, BasicBlock *IfNormal, \
BasicBlock *IfException,
const std::vector<Value*> &params,
const std::string &Name)
: TerminatorInst(cast<MethodType>(cast<PointerType>(Meth->getType())
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Meth->getType())
->getElementType())->getReturnType(),
Instruction::Invoke, Name) {
Operands.reserve(3+params.size());
Operands.push_back(Use(Meth, this));
Operands.push_back(Use(IfNormal, this));
Operands.push_back(Use(IfException, this));
const MethodType *MTy =
cast<MethodType>(cast<PointerType>(Meth->getType())->getElementType());
const FunctionType *MTy =
cast<FunctionType>(cast<PointerType>(Meth->getType())->getElementType());
const MethodType::ParamTypes &PL = MTy->getParamTypes();
const FunctionType::ParamTypes &PL = MTy->getParamTypes();
assert((params.size() == PL.size()) ||
(MTy->isVarArg() && params.size() > PL.size()) &&
"Calling a function with bad signature");

View File

@ -25,10 +25,10 @@ string MangleTypeName(const Type *Ty) {
mangledName += MangleTypeName(STy->getContainedType(i));
} else if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
mangledName = string("A_" +MangleTypeName(ATy->getElementType()));
} else if (MethodType *MTy = dyn_cast<MethodType>(Ty)) {
mangledName = string("M_") + MangleTypeName(MTy->getReturnType());
for (unsigned i = 1; i < MTy->getNumContainedTypes(); ++i)
mangledName += string(MangleTypeName(MTy->getContainedType(i)));
} else if (FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
mangledName = string("M_") + MangleTypeName(FTy->getReturnType());
for (unsigned i = 1; i < FTy->getNumContainedTypes(); ++i)
mangledName += string(MangleTypeName(FTy->getContainedType(i)));
}
return mangledName;