Add support for extern varargs methods & varargs method calls

Remove tool generated files


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-07-25 22:47:46 +00:00
parent 793d678316
commit 8b81bf5046
4 changed files with 37 additions and 2184 deletions

File diff suppressed because it is too large Load Diff

View File

@ -94,6 +94,7 @@ true { return TRUE; }
false { return FALSE; }
declare { return DECLARE; }
implementation { return IMPLEMENTATION; }
\.\.\. { return DOTDOTDOT; }
void { llvmAsmlval.TypeVal = Type::VoidTy ; return VOID; }
bool { llvmAsmlval.TypeVal = Type::BoolTy ; return BOOL; }

View File

@ -1,91 +0,0 @@
typedef union {
Module *ModuleVal;
Method *MethodVal;
MethodArgument *MethArgVal;
BasicBlock *BasicBlockVal;
TerminatorInst *TermInstVal;
Instruction *InstVal;
ConstPoolVal *ConstVal;
const Type *TypeVal;
list<MethodArgument*> *MethodArgList;
list<Value*> *ValueList;
list<const Type*> *TypeList;
list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node
list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable;
vector<ConstPoolVal*> *ConstVector;
int64_t SInt64Val;
uint64_t UInt64Val;
int SIntVal;
unsigned UIntVal;
double FPVal;
char *StrVal; // This memory is allocated by strdup!
ValID ValIDVal; // May contain memory allocated by strdup
Instruction::UnaryOps UnaryOpVal;
Instruction::BinaryOps BinaryOpVal;
Instruction::TermOps TermOpVal;
Instruction::MemoryOps MemOpVal;
Instruction::OtherOps OtherOpVal;
} YYSTYPE;
#define ESINT64VAL 257
#define EUINT64VAL 258
#define SINTVAL 259
#define UINTVAL 260
#define FPVAL 261
#define VOID 262
#define BOOL 263
#define SBYTE 264
#define UBYTE 265
#define SHORT 266
#define USHORT 267
#define INT 268
#define UINT 269
#define LONG 270
#define ULONG 271
#define FLOAT 272
#define DOUBLE 273
#define STRING 274
#define TYPE 275
#define LABEL 276
#define VAR_ID 277
#define LABELSTR 278
#define STRINGCONSTANT 279
#define IMPLEMENTATION 280
#define TRUE 281
#define FALSE 282
#define BEGINTOK 283
#define END 284
#define DECLARE 285
#define TO 286
#define RET 287
#define BR 288
#define SWITCH 289
#define NOT 290
#define ADD 291
#define SUB 292
#define MUL 293
#define DIV 294
#define REM 295
#define SETLE 296
#define SETGE 297
#define SETLT 298
#define SETGT 299
#define SETEQ 300
#define SETNE 301
#define MALLOC 302
#define ALLOCA 303
#define FREE 304
#define LOAD 305
#define STORE 306
#define GETELEMENTPTR 307
#define PHI 308
#define CALL 309
#define CAST 310
#define SHL 311
#define SHR 312
extern YYSTYPE llvmAsmlval;

View File

@ -427,7 +427,7 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) {
%type <MethArgVal> ArgVal
%type <PHIList> PHIList
%type <ValueList> ValueRefList ValueRefListE // For call param lists
%type <TypeList> TypeList
%type <TypeList> TypeList ArgTypeList
%type <JumpTable> JumpTable
%type <ValIDVal> ValueRef ConstValueRef // Reference to a definition or BB
@ -455,7 +455,7 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) {
%type <StrVal> OptVAR_ID OptAssign
%token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE TO
%token IMPLEMENTATION TRUE FALSE BEGINTOK END DECLARE TO DOTDOTDOT
// Basic Block Terminating Operators
%token <TermOpVal> RET BR SWITCH
@ -713,6 +713,10 @@ ArgListH : ArgVal ',' ArgListH {
$$ = new list<MethodArgument*>();
$$->push_front($1);
}
| DOTDOTDOT {
$$ = new list<MethodArgument*>();
$$->push_back(new MethodArgument(Type::VoidTy));
}
ArgList : ArgListH {
$$ = $1;
@ -819,7 +823,7 @@ Types : ValueRef {
ConstPoolType *CPT = (ConstPoolType*)D->castConstantAsserting();
$$ = CPT->getValue();
}
| TypesV '(' TypeList ')' { // Method derived type?
| TypesV '(' ArgTypeList ')' { // Method derived type?
MethodType::ParamTypes Params($3->begin(), $3->end());
delete $3;
$$ = checkNewType(MethodType::getMethodType($1, Params));
@ -846,7 +850,6 @@ Types : ValueRef {
$$ = checkNewType(PointerType::getPointerType($1));
}
TypeList : Types {
$$ = new list<const Type*>();
$$->push_back($1);
@ -855,6 +858,11 @@ TypeList : Types {
($$=$1)->push_back($3);
}
ArgTypeList : TypeList
| TypeList ',' DOTDOTDOT {
($$=$1)->push_back(Type::VoidTy);
}
BasicBlockList : BasicBlockList BasicBlock {
$1->getBasicBlocks().push_back($2);
@ -995,41 +1003,41 @@ InstVal : BinaryOps Types ValueRef ',' ValueRef {
delete $2; // Free the list...
}
| CALL Types ValueRef '(' ValueRefListE ')' {
if (!$2->isMethodType())
ThrowException("Can only call methods: invalid type '" +
$2->getName() + "'!");
const MethodType *Ty;
const MethodType *Ty = (const MethodType*)$2;
if (!(Ty = $2->isMethodType())) {
// Pull out the types of all of the arguments...
vector<const Type*> ParamTypes;
for (list<Value*>::iterator I = $5->begin(), E = $5->end(); I != E; ++I)
ParamTypes.push_back((*I)->getType());
Ty = MethodType::get($2, ParamTypes);
}
Value *V = getVal(Ty, $3);
if (!V->isMethod() || V->getType() != Ty)
ThrowException("Cannot call: " + $3.getName() + "!");
// Create or access a new type that corresponds to the function call...
vector<Value *> Params;
if ($5) {
// Pull out just the arguments...
Params.insert(Params.begin(), $5->begin(), $5->end());
delete $5;
Value *V = getVal(Ty, $3); // Get the method we're calling...
// Create the call node...
if (!$5) { // Has no arguments?
$$ = new CallInst(V->castMethodAsserting(), vector<Value*>());
} else { // Has arguments?
// Loop through MethodType's arguments and ensure they are specified
// correctly!
//
MethodType::ParamTypes::const_iterator I = Ty->getParamTypes().begin();
unsigned i;
for (i = 0; i < Params.size() && I != Ty->getParamTypes().end(); ++i,++I){
if (Params[i]->getType() != *I)
ThrowException("Parameter " + utostr(i) + " is not of type '" +
MethodType::ParamTypes::const_iterator E = Ty->getParamTypes().end();
list<Value*>::iterator ArgI = $5->begin(), ArgE = $5->end();
for (; ArgI != ArgE && I != E; ++ArgI, ++I)
if ((*ArgI)->getType() != *I)
ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" +
(*I)->getName() + "'!");
}
if (i != Params.size() || I != Ty->getParamTypes().end())
if (I != E || (ArgI != ArgE && !Ty->isVarArg()))
ThrowException("Invalid number of parameters detected!");
}
// Create the call node...
$$ = new CallInst((Method*)V, Params);
$$ = new CallInst(V->castMethodAsserting(),
vector<Value*>($5->begin(), $5->end()));
}
delete $5;
}
| MemoryInst {
$$ = $1;