Added lexer and parser support for the extractelement operation.

llvm-svn: 25177
This commit is contained in:
Robert Bocchino 2006-01-10 19:04:32 +00:00
parent 4dc697098e
commit aa1cf5440e
5 changed files with 1162 additions and 1104 deletions

File diff suppressed because it is too large Load Diff

View File

@ -272,6 +272,8 @@ load { RET_TOK(MemOpVal, Load, LOAD); }
store { RET_TOK(MemOpVal, Store, STORE); }
getelementptr { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
extractelement { RET_TOK(OtherOpVal, ExtractElement, EXTRACTELEMENT); }
{VarID} {
UnEscapeLexed(yytext+1);

File diff suppressed because it is too large Load Diff

View File

@ -128,8 +128,9 @@ typedef union {
#define SHL 345
#define SHR 346
#define VAARG 347
#define VAARG_old 348
#define VANEXT_old 349
#define EXTRACTELEMENT 348
#define VAARG_old 349
#define VANEXT_old 350
extern YYSTYPE llvmAsmlval;

View File

@ -979,7 +979,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
// Other Operators
%type <OtherOpVal> ShiftOps
%token <OtherOpVal> PHI_TOK CAST SELECT SHL SHR VAARG
%token <OtherOpVal> PHI_TOK CAST SELECT SHL SHR VAARG EXTRACTELEMENT
%token VAARG_old VANEXT_old //OBSOLETE
@ -1519,9 +1519,16 @@ ConstExpr: CAST '(' ConstVal TO Types ')' {
if (!$3->getType()->isInteger())
ThrowException("Shift constant expression requires integer operand!");
$$ = ConstantExpr::get($1, $3, $5);
}
| EXTRACTELEMENT '(' ConstVal ',' ConstVal ')' {
if (!isa<PackedType>($3->getType()))
ThrowException("First operand of extractelement must be "
"packed type!");
if ($5->getType() != Type::UIntTy)
ThrowException("Second operand of extractelement must be uint!");
$$ = ConstantExpr::getExtractElement($3, $5);
};
// ConstVector - A list of comma separated constants.
ConstVector : ConstVector ',' ConstVal {
($$ = $1)->push_back($3);
@ -2181,6 +2188,14 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
$$ = new LoadInst(foo);
delete $4;
}
| EXTRACTELEMENT ResolvedVal ',' ResolvedVal {
if (!isa<PackedType>($2->getType()))
ThrowException("First operand of extractelement must be a "
"packed type val!");
if ($4->getType() != Type::UIntTy)
ThrowException("Second operand of extractelement must be a uint!");
$$ = new ExtractElementInst($2, $4);
}
| PHI_TOK PHIList {
const Type *Ty = $2->front().first->getType();
if (!Ty->isFirstClassType())