forked from OSchip/llvm-project
AsmParser support for immediate constant aggregate values.
llvm-svn: 52149
This commit is contained in:
parent
401ef2e426
commit
3ab46f1383
File diff suppressed because it is too large
Load Diff
|
@ -402,7 +402,7 @@ typedef union YYSTYPE
|
||||||
llvm::ICmpInst::Predicate IPredicate;
|
llvm::ICmpInst::Predicate IPredicate;
|
||||||
llvm::FCmpInst::Predicate FPredicate;
|
llvm::FCmpInst::Predicate FPredicate;
|
||||||
}
|
}
|
||||||
/* Line 1529 of yacc.c. */
|
/* Line 1489 of yacc.c. */
|
||||||
#line 407 "llvmAsmParser.tab.h"
|
#line 407 "llvmAsmParser.tab.h"
|
||||||
YYSTYPE;
|
YYSTYPE;
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
|
|
|
@ -2485,13 +2485,7 @@ ConstValueRef : ESINT64VAL { // A reference to a direct constant
|
||||||
GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
|
GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
|
||||||
|
|
||||||
VectorType* pt = VectorType::get(ETy, NumElements);
|
VectorType* pt = VectorType::get(ETy, NumElements);
|
||||||
PATypeHolder* PTy = new PATypeHolder(
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
|
||||||
HandleUpRefs(
|
|
||||||
VectorType::get(
|
|
||||||
ETy,
|
|
||||||
NumElements)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verify all elements are correct type!
|
// Verify all elements are correct type!
|
||||||
for (unsigned i = 0; i < $2->size(); i++) {
|
for (unsigned i = 0; i < $2->size(); i++) {
|
||||||
|
@ -2505,6 +2499,80 @@ ConstValueRef : ESINT64VAL { // A reference to a direct constant
|
||||||
delete PTy; delete $2;
|
delete PTy; delete $2;
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
}
|
}
|
||||||
|
| '[' ConstVector ']' { // Nonempty unsized arr
|
||||||
|
const Type *ETy = (*$2)[0]->getType();
|
||||||
|
int NumElements = $2->size();
|
||||||
|
|
||||||
|
if (!ETy->isFirstClassType())
|
||||||
|
GEN_ERROR("Invalid array element type: " + ETy->getDescription());
|
||||||
|
|
||||||
|
ArrayType *ATy = ArrayType::get(ETy, NumElements);
|
||||||
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
|
||||||
|
|
||||||
|
// Verify all elements are correct type!
|
||||||
|
for (unsigned i = 0; i < $2->size(); i++) {
|
||||||
|
if (ETy != (*$2)[i]->getType())
|
||||||
|
GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
|
||||||
|
ETy->getDescription() +"' as required!\nIt is of type '"+
|
||||||
|
(*$2)[i]->getType()->getDescription() + "'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$$ = ValID::create(ConstantArray::get(ATy, *$2));
|
||||||
|
delete PTy; delete $2;
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '[' ']' {
|
||||||
|
$$ = ValID::createUndef();
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| 'c' STRINGCONSTANT {
|
||||||
|
int NumElements = $2->length();
|
||||||
|
const Type *ETy = Type::Int8Ty;
|
||||||
|
|
||||||
|
ArrayType *ATy = ArrayType::get(ETy, NumElements);
|
||||||
|
|
||||||
|
std::vector<Constant*> Vals;
|
||||||
|
for (unsigned i = 0; i < $2->length(); ++i)
|
||||||
|
Vals.push_back(ConstantInt::get(ETy, (*$2)[i]));
|
||||||
|
delete $2;
|
||||||
|
$$ = ValID::create(ConstantArray::get(ATy, Vals));
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '{' ConstVector '}' {
|
||||||
|
std::vector<const Type*> Elements($2->size());
|
||||||
|
for (unsigned i = 0, e = $2->size(); i != e; ++i)
|
||||||
|
Elements[i] = (*$2)[i]->getType();
|
||||||
|
|
||||||
|
const StructType *STy = StructType::get(Elements);
|
||||||
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
|
||||||
|
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, *$2));
|
||||||
|
delete PTy; delete $2;
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '{' '}' {
|
||||||
|
const StructType *STy = StructType::get(std::vector<const Type*>());
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '<' '{' ConstVector '}' '>' {
|
||||||
|
std::vector<const Type*> Elements($3->size());
|
||||||
|
for (unsigned i = 0, e = $3->size(); i != e; ++i)
|
||||||
|
Elements[i] = (*$3)[i]->getType();
|
||||||
|
|
||||||
|
const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
|
||||||
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
|
||||||
|
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, *$3));
|
||||||
|
delete PTy; delete $3;
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '<' '{' '}' '>' {
|
||||||
|
const StructType *STy = StructType::get(std::vector<const Type*>(),
|
||||||
|
/*isPacked=*/true);
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
| ConstExpr {
|
| ConstExpr {
|
||||||
$$ = ValID::create($1);
|
$$ = ValID::create($1);
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
|
|
|
@ -2485,13 +2485,7 @@ ConstValueRef : ESINT64VAL { // A reference to a direct constant
|
||||||
GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
|
GEN_ERROR("Invalid vector element type: " + ETy->getDescription());
|
||||||
|
|
||||||
VectorType* pt = VectorType::get(ETy, NumElements);
|
VectorType* pt = VectorType::get(ETy, NumElements);
|
||||||
PATypeHolder* PTy = new PATypeHolder(
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(pt));
|
||||||
HandleUpRefs(
|
|
||||||
VectorType::get(
|
|
||||||
ETy,
|
|
||||||
NumElements)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verify all elements are correct type!
|
// Verify all elements are correct type!
|
||||||
for (unsigned i = 0; i < $2->size(); i++) {
|
for (unsigned i = 0; i < $2->size(); i++) {
|
||||||
|
@ -2505,6 +2499,80 @@ ConstValueRef : ESINT64VAL { // A reference to a direct constant
|
||||||
delete PTy; delete $2;
|
delete PTy; delete $2;
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
}
|
}
|
||||||
|
| '[' ConstVector ']' { // Nonempty unsized arr
|
||||||
|
const Type *ETy = (*$2)[0]->getType();
|
||||||
|
int NumElements = $2->size();
|
||||||
|
|
||||||
|
if (!ETy->isFirstClassType())
|
||||||
|
GEN_ERROR("Invalid array element type: " + ETy->getDescription());
|
||||||
|
|
||||||
|
ArrayType *ATy = ArrayType::get(ETy, NumElements);
|
||||||
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(ATy));
|
||||||
|
|
||||||
|
// Verify all elements are correct type!
|
||||||
|
for (unsigned i = 0; i < $2->size(); i++) {
|
||||||
|
if (ETy != (*$2)[i]->getType())
|
||||||
|
GEN_ERROR("Element #" + utostr(i) + " is not of type '" +
|
||||||
|
ETy->getDescription() +"' as required!\nIt is of type '"+
|
||||||
|
(*$2)[i]->getType()->getDescription() + "'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$$ = ValID::create(ConstantArray::get(ATy, *$2));
|
||||||
|
delete PTy; delete $2;
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '[' ']' {
|
||||||
|
$$ = ValID::createUndef();
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| 'c' STRINGCONSTANT {
|
||||||
|
int NumElements = $2->length();
|
||||||
|
const Type *ETy = Type::Int8Ty;
|
||||||
|
|
||||||
|
ArrayType *ATy = ArrayType::get(ETy, NumElements);
|
||||||
|
|
||||||
|
std::vector<Constant*> Vals;
|
||||||
|
for (unsigned i = 0; i < $2->length(); ++i)
|
||||||
|
Vals.push_back(ConstantInt::get(ETy, (*$2)[i]));
|
||||||
|
delete $2;
|
||||||
|
$$ = ValID::create(ConstantArray::get(ATy, Vals));
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '{' ConstVector '}' {
|
||||||
|
std::vector<const Type*> Elements($2->size());
|
||||||
|
for (unsigned i = 0, e = $2->size(); i != e; ++i)
|
||||||
|
Elements[i] = (*$2)[i]->getType();
|
||||||
|
|
||||||
|
const StructType *STy = StructType::get(Elements);
|
||||||
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
|
||||||
|
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, *$2));
|
||||||
|
delete PTy; delete $2;
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '{' '}' {
|
||||||
|
const StructType *STy = StructType::get(std::vector<const Type*>());
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '<' '{' ConstVector '}' '>' {
|
||||||
|
std::vector<const Type*> Elements($3->size());
|
||||||
|
for (unsigned i = 0, e = $3->size(); i != e; ++i)
|
||||||
|
Elements[i] = (*$3)[i]->getType();
|
||||||
|
|
||||||
|
const StructType *STy = StructType::get(Elements, /*isPacked=*/true);
|
||||||
|
PATypeHolder* PTy = new PATypeHolder(HandleUpRefs(STy));
|
||||||
|
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, *$3));
|
||||||
|
delete PTy; delete $3;
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
|
| '<' '{' '}' '>' {
|
||||||
|
const StructType *STy = StructType::get(std::vector<const Type*>(),
|
||||||
|
/*isPacked=*/true);
|
||||||
|
$$ = ValID::create(ConstantStruct::get(STy, std::vector<Constant*>()));
|
||||||
|
CHECK_FOR_ERROR
|
||||||
|
}
|
||||||
| ConstExpr {
|
| ConstExpr {
|
||||||
$$ = ValID::create($1);
|
$$ = ValID::create($1);
|
||||||
CHECK_FOR_ERROR
|
CHECK_FOR_ERROR
|
||||||
|
|
|
@ -295,6 +295,13 @@ ConstValueRef ::= ESINT64VAL
|
||||||
| undef
|
| undef
|
||||||
| zeroinitializer
|
| zeroinitializer
|
||||||
| "<" ConstVector ">"
|
| "<" ConstVector ">"
|
||||||
|
| "[" ConstVector "]"
|
||||||
|
| "[" "]"
|
||||||
|
| "c" ^ STRINGCONSTANT
|
||||||
|
| "{" ConstVector "}"
|
||||||
|
| "{" "}"
|
||||||
|
| "<" ^ "{" ConstVector "}" ^ ">"
|
||||||
|
| "<" ^ "{" "}" ^ ">"
|
||||||
| ConstExpr
|
| ConstExpr
|
||||||
| asm OptSideEffect STRINGCONSTANT ^ "," STRINGCONSTANT ;
|
| asm OptSideEffect STRINGCONSTANT ^ "," STRINGCONSTANT ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue