mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
s/Method/Function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2035 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -18,7 +18,7 @@ public:
|
|||||||
Module = 0x01,
|
Module = 0x01,
|
||||||
|
|
||||||
// Module subtypes:
|
// Module subtypes:
|
||||||
Method = 0x11,
|
Function = 0x11,
|
||||||
ConstantPool,
|
ConstantPool,
|
||||||
SymbolTable,
|
SymbolTable,
|
||||||
ModuleGlobalInfo,
|
ModuleGlobalInfo,
|
||||||
|
@ -28,7 +28,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
|
|||||||
return Val;
|
return Val;
|
||||||
|
|
||||||
switch (PrimType) {
|
switch (PrimType) {
|
||||||
case Type::MethodTyID: {
|
case Type::FunctionTyID: {
|
||||||
unsigned Typ;
|
unsigned Typ;
|
||||||
if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
|
if (read_vbr(Buf, EndBuf, Typ)) return failure(Val);
|
||||||
const Type *RetType = getType(Typ);
|
const Type *RetType = getType(Typ);
|
||||||
@ -48,7 +48,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf,
|
|||||||
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
|
bool isVarArg = Params.size() && Params.back() == Type::VoidTy;
|
||||||
if (isVarArg) Params.pop_back();
|
if (isVarArg) Params.pop_back();
|
||||||
|
|
||||||
return MethodType::get(RetType, Params, isVarArg);
|
return FunctionType::get(RetType, Params, isVarArg);
|
||||||
}
|
}
|
||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
unsigned ElTyp;
|
unsigned ElTyp;
|
||||||
|
@ -116,7 +116,7 @@ Value *BytecodeParser::getValue(const Type *Ty, unsigned oNum, bool Create) {
|
|||||||
Value *d = 0;
|
Value *d = 0;
|
||||||
switch (Ty->getPrimitiveID()) {
|
switch (Ty->getPrimitiveID()) {
|
||||||
case Type::LabelTyID: d = new BBPHolder(Ty, oNum); break;
|
case Type::LabelTyID: d = new BBPHolder(Ty, oNum); break;
|
||||||
case Type::MethodTyID:
|
case Type::FunctionTyID:
|
||||||
cerr << "Creating method pholder! : " << type << ":" << oNum << " "
|
cerr << "Creating method pholder! : " << type << ":" << oNum << " "
|
||||||
<< Ty->getName() << "\n";
|
<< Ty->getName() << "\n";
|
||||||
d = new MethPHolder(Ty, oNum);
|
d = new MethPHolder(Ty, oNum);
|
||||||
@ -260,12 +260,12 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
// Clear out the local values table...
|
// Clear out the local values table...
|
||||||
Values.clear();
|
Values.clear();
|
||||||
if (MethodSignatureList.empty()) {
|
if (MethodSignatureList.empty()) {
|
||||||
Error = "Method found, but MethodSignatureList empty!";
|
Error = "Function found, but FunctionSignatureList empty!";
|
||||||
return failure(true); // Unexpected method!
|
return failure(true); // Unexpected method!
|
||||||
}
|
}
|
||||||
|
|
||||||
const PointerType *PMTy = MethodSignatureList.front().first; // PtrMeth
|
const PointerType *PMTy = MethodSignatureList.front().first; // PtrMeth
|
||||||
const MethodType *MTy = dyn_cast<const MethodType>(PMTy->getElementType());
|
const FunctionType *MTy = dyn_cast<FunctionType>(PMTy->getElementType());
|
||||||
if (MTy == 0) return failure(true); // Not ptr to method!
|
if (MTy == 0) return failure(true); // Not ptr to method!
|
||||||
|
|
||||||
unsigned isInternal;
|
unsigned isInternal;
|
||||||
@ -273,12 +273,12 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
|
|
||||||
unsigned MethSlot = MethodSignatureList.front().second;
|
unsigned MethSlot = MethodSignatureList.front().second;
|
||||||
MethodSignatureList.pop_front();
|
MethodSignatureList.pop_front();
|
||||||
Method *M = new Method(MTy, isInternal != 0);
|
Function *M = new Function(MTy, isInternal != 0);
|
||||||
|
|
||||||
BCR_TRACE(2, "METHOD TYPE: " << MTy << "\n");
|
BCR_TRACE(2, "METHOD TYPE: " << MTy << "\n");
|
||||||
|
|
||||||
const MethodType::ParamTypes &Params = MTy->getParamTypes();
|
const FunctionType::ParamTypes &Params = MTy->getParamTypes();
|
||||||
for (MethodType::ParamTypes::const_iterator It = Params.begin();
|
for (FunctionType::ParamTypes::const_iterator It = Params.begin();
|
||||||
It != Params.end(); ++It) {
|
It != Params.end(); ++It) {
|
||||||
FunctionArgument *FA = new FunctionArgument(*It);
|
FunctionArgument *FA = new FunctionArgument(*It);
|
||||||
if (insertValue(FA, Values) == -1) {
|
if (insertValue(FA, Values) == -1) {
|
||||||
@ -292,7 +292,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
unsigned Type, Size;
|
unsigned Type, Size;
|
||||||
const uchar *OldBuf = Buf;
|
const uchar *OldBuf = Buf;
|
||||||
if (readBlock(Buf, EndBuf, Type, Size)) {
|
if (readBlock(Buf, EndBuf, Type, Size)) {
|
||||||
Error = "Error reading Method level block!";
|
Error = "Error reading Function level block!";
|
||||||
delete M; return failure(true);
|
delete M; return failure(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
BCR_TRACE(2, "} end block\n");
|
BCR_TRACE(2, "} end block\n");
|
||||||
|
|
||||||
if (align32(Buf, EndBuf)) {
|
if (align32(Buf, EndBuf)) {
|
||||||
Error = "Error aligning Method level block!";
|
Error = "Error aligning Function level block!";
|
||||||
delete M; // Malformed bc file, read past end of block.
|
delete M; // Malformed bc file, read past end of block.
|
||||||
return failure(true);
|
return failure(true);
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
|
|||||||
|
|
||||||
Value *MethPHolder = getValue(PMTy, MethSlot, false);
|
Value *MethPHolder = getValue(PMTy, MethSlot, false);
|
||||||
assert(MethPHolder && "Something is broken no placeholder found!");
|
assert(MethPHolder && "Something is broken no placeholder found!");
|
||||||
assert(isa<Method>(MethPHolder) && "Not a method?");
|
assert(isa<Function>(MethPHolder) && "Not a function?");
|
||||||
|
|
||||||
unsigned type; // Type slot
|
unsigned type; // Type slot
|
||||||
assert(!getTypeSlot(MTy, type) && "How can meth type not exist?");
|
assert(!getTypeSlot(MTy, type) && "How can meth type not exist?");
|
||||||
@ -433,12 +433,12 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
|
|||||||
while (MethSignature != Type::VoidTyID) { // List is terminated by Void
|
while (MethSignature != Type::VoidTyID) { // List is terminated by Void
|
||||||
const Type *Ty = getType(MethSignature);
|
const Type *Ty = getType(MethSignature);
|
||||||
if (!Ty || !isa<PointerType>(Ty) ||
|
if (!Ty || !isa<PointerType>(Ty) ||
|
||||||
!isa<MethodType>(cast<PointerType>(Ty)->getElementType())) {
|
!isa<FunctionType>(cast<PointerType>(Ty)->getElementType())) {
|
||||||
Error = "Method not ptr to meth type! Ty = " + Ty->getDescription();
|
Error = "Function not ptr to func type! Ty = " + Ty->getDescription();
|
||||||
return failure(true);
|
return failure(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We create methods by passing the underlying MethodType to create...
|
// We create methods by passing the underlying FunctionType to create...
|
||||||
Ty = cast<PointerType>(Ty)->getElementType();
|
Ty = cast<PointerType>(Ty)->getElementType();
|
||||||
|
|
||||||
// When the ModuleGlobalInfo section is read, we load the type of each
|
// When the ModuleGlobalInfo section is read, we load the type of each
|
||||||
@ -462,7 +462,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
|
|||||||
MethodSignatureList.push_back(
|
MethodSignatureList.push_back(
|
||||||
make_pair(cast<const PointerType>(Val->getType()), SlotNo));
|
make_pair(cast<const PointerType>(Val->getType()), SlotNo));
|
||||||
if (read_vbr(Buf, End, MethSignature)) return failure(true);
|
if (read_vbr(Buf, End, MethSignature)) return failure(true);
|
||||||
BCR_TRACE(2, "Method of type: " << Ty << "\n");
|
BCR_TRACE(2, "Function of type: " << Ty << "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (align32(Buf, End)) return failure(true);
|
if (align32(Buf, End)) return failure(true);
|
||||||
@ -512,8 +512,8 @@ bool BytecodeParser::ParseModule(const uchar *Buf, const uchar *EndBuf,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BytecodeFormat::Method: {
|
case BytecodeFormat::Function: {
|
||||||
BCR_TRACE(1, "BLOCK BytecodeFormat::Method: {\n");
|
BCR_TRACE(1, "BLOCK BytecodeFormat::Function: {\n");
|
||||||
if (ParseMethod(Buf, Buf+Size, C)) {
|
if (ParseMethod(Buf, Buf+Size, C)) {
|
||||||
delete C; return failure(true); // Error parsing method
|
delete C; return failure(true); // Error parsing method
|
||||||
}
|
}
|
||||||
@ -538,7 +538,7 @@ bool BytecodeParser::ParseModule(const uchar *Buf, const uchar *EndBuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!MethodSignatureList.empty()) { // Expected more methods!
|
if (!MethodSignatureList.empty()) { // Expected more methods!
|
||||||
Error = "Method expected, but bytecode stream at end!";
|
Error = "Function expected, but bytecode stream at end!";
|
||||||
return failure(true);
|
return failure(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include "llvm/Bytecode/Primitives.h"
|
#include "llvm/Bytecode/Primitives.h"
|
||||||
#include "llvm/SymTabValue.h"
|
#include "llvm/SymTabValue.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
@ -143,9 +143,9 @@ struct BBPlaceHolderHelper : public BasicBlock {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MethPlaceHolderHelper : public Method {
|
struct MethPlaceHolderHelper : public Function {
|
||||||
MethPlaceHolderHelper(const Type *Ty)
|
MethPlaceHolderHelper(const Type *Ty)
|
||||||
: Method(cast<const MethodType>(Ty), true) {
|
: Function(cast<const FunctionType>(Ty), true) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,9 +155,9 @@ typedef PlaceholderDef<MethPlaceHolderHelper> MethPHolder;
|
|||||||
|
|
||||||
static inline unsigned getValueIDNumberFromPlaceHolder(Value *Def) {
|
static inline unsigned getValueIDNumberFromPlaceHolder(Value *Def) {
|
||||||
switch (Def->getType()->getPrimitiveID()) {
|
switch (Def->getType()->getPrimitiveID()) {
|
||||||
case Type::LabelTyID: return ((BBPHolder*)Def)->getID();
|
case Type::LabelTyID: return ((BBPHolder*)Def)->getID();
|
||||||
case Type::MethodTyID: return ((MethPHolder*)Def)->getID();
|
case Type::FunctionTyID: return ((MethPHolder*)Def)->getID();
|
||||||
default: return ((DefPHolder*)Def)->getID();
|
default: return ((DefPHolder*)Def)->getID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ void BytecodeWriter::outputType(const Type *T) {
|
|||||||
return; // We might do this if we alias a prim type: %x = type int
|
return; // We might do this if we alias a prim type: %x = type int
|
||||||
|
|
||||||
switch (T->getPrimitiveID()) { // Handle derived types now.
|
switch (T->getPrimitiveID()) { // Handle derived types now.
|
||||||
case Type::MethodTyID: {
|
case Type::FunctionTyID: {
|
||||||
const MethodType *MT = cast<const MethodType>(T);
|
const FunctionType *MT = cast<const FunctionType>(T);
|
||||||
int Slot = Table.getValSlot(MT->getReturnType());
|
int Slot = Table.getValSlot(MT->getReturnType());
|
||||||
assert(Slot != -1 && "Type used but not available!!");
|
assert(Slot != -1 && "Type used but not available!!");
|
||||||
output_vbr((unsigned)Slot, Out);
|
output_vbr((unsigned)Slot, Out);
|
||||||
@ -34,7 +34,7 @@ void BytecodeWriter::outputType(const Type *T) {
|
|||||||
output_vbr(MT->getParamTypes().size()+MT->isVarArg(), Out);
|
output_vbr(MT->getParamTypes().size()+MT->isVarArg(), Out);
|
||||||
|
|
||||||
// Output all of the arguments...
|
// Output all of the arguments...
|
||||||
MethodType::ParamTypes::const_iterator I = MT->getParamTypes().begin();
|
FunctionType::ParamTypes::const_iterator I = MT->getParamTypes().begin();
|
||||||
for (; I != MT->getParamTypes().end(); ++I) {
|
for (; I != MT->getParamTypes().end(); ++I) {
|
||||||
Slot = Table.getValSlot(*I);
|
Slot = Table.getValSlot(*I);
|
||||||
assert(Slot != -1 && "Type used but not available!!");
|
assert(Slot != -1 && "Type used but not available!!");
|
||||||
|
@ -150,7 +150,7 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BytecodeWriter::processMethod(const Function *M) {
|
void BytecodeWriter::processMethod(const Function *M) {
|
||||||
BytecodeBlock FunctionBlock(BytecodeFormat::Method, Out);
|
BytecodeBlock FunctionBlock(BytecodeFormat::Function, Out);
|
||||||
output_vbr((unsigned)M->hasInternalLinkage(), Out);
|
output_vbr((unsigned)M->hasInternalLinkage(), Out);
|
||||||
// Only output the constant pool and other goodies if needed...
|
// Only output the constant pool and other goodies if needed...
|
||||||
if (!M->isExternal()) {
|
if (!M->isExternal()) {
|
||||||
|
@ -304,8 +304,9 @@ public:
|
|||||||
Type::PrimitiveID ty = type->getPrimitiveID();
|
Type::PrimitiveID ty = type->getPrimitiveID();
|
||||||
unsigned res;
|
unsigned res;
|
||||||
|
|
||||||
|
// FIXME: Comparing types like this isn't very safe...
|
||||||
if ((ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) ||
|
if ((ty && ty <= Type::LongTyID) || (ty == Type::LabelTyID) ||
|
||||||
(ty == Type::MethodTyID) || (ty == Type::PointerTyID) )
|
(ty == Type::FunctionTyID) || (ty == Type::PointerTyID) )
|
||||||
res = IntRegClassID; // sparc int reg (ty=0: void)
|
res = IntRegClassID; // sparc int reg (ty=0: void)
|
||||||
else if (ty <= Type::DoubleTyID)
|
else if (ty <= Type::DoubleTyID)
|
||||||
res = FloatRegClassID; // sparc float reg class
|
res = FloatRegClassID; // sparc float reg class
|
||||||
|
Reference in New Issue
Block a user