mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
fix the varargs version of StructType::get to not require an LLVMContext, making usage
much cleaner. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133364 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -237,14 +237,13 @@ public:
|
|||||||
|
|
||||||
/// StructType::get - Create an empty structure type.
|
/// StructType::get - Create an empty structure type.
|
||||||
///
|
///
|
||||||
static StructType *get(LLVMContext &Context, bool isPacked=false);
|
static StructType *get(LLVMContext &Context, bool isPacked = false);
|
||||||
|
|
||||||
/// StructType::get - This static method is a convenience method for
|
/// StructType::get - This static method is a convenience method for creating
|
||||||
/// creating structure types by specifying the elements as arguments.
|
/// structure types by specifying the elements as arguments. Note that this
|
||||||
/// Note that this method always returns a non-packed struct. To get
|
/// method always returns a non-packed struct, and requires at least one
|
||||||
/// an empty struct, pass NULL, NULL.
|
/// element type.
|
||||||
static StructType *get(LLVMContext &Context,
|
static StructType *get(const Type *elt1, ...) END_WITH_NULL;
|
||||||
const Type *type, ...) END_WITH_NULL;
|
|
||||||
|
|
||||||
/// isValidElementType - Return true if the specified type is valid as a
|
/// isValidElementType - Return true if the specified type is valid as a
|
||||||
/// element type.
|
/// element type.
|
||||||
|
@@ -91,8 +91,7 @@ bool SjLjEHPass::doInitialization(Module &M) {
|
|||||||
Type::getInt8PtrTy(M.getContext());
|
Type::getInt8PtrTy(M.getContext());
|
||||||
const Type *Int32Ty = Type::getInt32Ty(M.getContext());
|
const Type *Int32Ty = Type::getInt32Ty(M.getContext());
|
||||||
FunctionContextTy =
|
FunctionContextTy =
|
||||||
StructType::get(M.getContext(),
|
StructType::get(VoidPtrTy, // __prev
|
||||||
VoidPtrTy, // __prev
|
|
||||||
Int32Ty, // call_site
|
Int32Ty, // call_site
|
||||||
ArrayType::get(Int32Ty, 4), // __data
|
ArrayType::get(Int32Ty, 4), // __data
|
||||||
VoidPtrTy, // __personality
|
VoidPtrTy, // __personality
|
||||||
|
@@ -376,7 +376,7 @@ namespace llvm {
|
|||||||
public:
|
public:
|
||||||
static const StructType *get(LLVMContext& C) {
|
static const StructType *get(LLVMContext& C) {
|
||||||
return( StructType::get(
|
return( StructType::get(
|
||||||
C, TypeBuilder<types::i<32>, xcompile>::get(C), // type
|
TypeBuilder<types::i<32>, xcompile>::get(C), // type
|
||||||
TypeBuilder<types::i<32>, xcompile>::get(C), // array size
|
TypeBuilder<types::i<32>, xcompile>::get(C), // array size
|
||||||
TypeBuilder<types::i<8>*, xcompile>::get(C), // array/hash ptr
|
TypeBuilder<types::i<8>*, xcompile>::get(C), // array/hash ptr
|
||||||
NULL));
|
NULL));
|
||||||
|
@@ -1537,8 +1537,8 @@ Constant *ConstantExpr::getSizeOf(const Type* Ty) {
|
|||||||
Constant *ConstantExpr::getAlignOf(const Type* Ty) {
|
Constant *ConstantExpr::getAlignOf(const Type* Ty) {
|
||||||
// alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
|
// alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1
|
||||||
// Note that a non-inbounds gep is used, as null isn't within any object.
|
// Note that a non-inbounds gep is used, as null isn't within any object.
|
||||||
const Type *AligningTy = StructType::get(Ty->getContext(),
|
const Type *AligningTy =
|
||||||
Type::getInt1Ty(Ty->getContext()), Ty, NULL);
|
StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, NULL);
|
||||||
Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo());
|
Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo());
|
||||||
Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
|
Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0);
|
||||||
Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1);
|
||||||
|
@@ -939,15 +939,17 @@ StructType *StructType::get(LLVMContext &Context,
|
|||||||
return ST;
|
return ST;
|
||||||
}
|
}
|
||||||
|
|
||||||
StructType *StructType::get(LLVMContext &Context, const Type *type, ...) {
|
StructType *StructType::get(const Type *type, ...) {
|
||||||
|
assert(type != 0 && "Cannot create a struct type with no elements with this");
|
||||||
|
LLVMContext &Ctx = type->getContext();
|
||||||
va_list ap;
|
va_list ap;
|
||||||
std::vector<const llvm::Type*> StructFields;
|
SmallVector<const llvm::Type*, 8> StructFields;
|
||||||
va_start(ap, type);
|
va_start(ap, type);
|
||||||
while (type) {
|
while (type) {
|
||||||
StructFields.push_back(type);
|
StructFields.push_back(type);
|
||||||
type = va_arg(ap, llvm::Type*);
|
type = va_arg(ap, llvm::Type*);
|
||||||
}
|
}
|
||||||
return llvm::StructType::get(Context, StructFields);
|
return llvm::StructType::get(Ctx, StructFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StructType::isValidElementType(const Type *ElemTy) {
|
bool StructType::isValidElementType(const Type *ElemTy) {
|
||||||
|
@@ -231,19 +231,19 @@ public:
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
TEST(TypeBuilderTest, Extensions) {
|
TEST(TypeBuilderTest, Extensions) {
|
||||||
EXPECT_EQ(PointerType::getUnqual(StructType::get(getGlobalContext(),
|
EXPECT_EQ(PointerType::getUnqual(StructType::get(
|
||||||
TypeBuilder<int, false>::get(getGlobalContext()),
|
TypeBuilder<int, false>::get(getGlobalContext()),
|
||||||
TypeBuilder<int*, false>::get(getGlobalContext()),
|
TypeBuilder<int*, false>::get(getGlobalContext()),
|
||||||
TypeBuilder<void*[], false>::get(getGlobalContext()),
|
TypeBuilder<void*[], false>::get(getGlobalContext()),
|
||||||
NULL)),
|
NULL)),
|
||||||
(TypeBuilder<MyType*, false>::get(getGlobalContext())));
|
(TypeBuilder<MyType*, false>::get(getGlobalContext())));
|
||||||
EXPECT_EQ(PointerType::getUnqual(StructType::get(getGlobalContext(),
|
EXPECT_EQ(PointerType::getUnqual(StructType::get(
|
||||||
TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
|
TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
|
||||||
TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
|
TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
|
||||||
TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
|
TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
|
||||||
NULL)),
|
NULL)),
|
||||||
(TypeBuilder<MyPortableType*, false>::get(getGlobalContext())));
|
(TypeBuilder<MyPortableType*, false>::get(getGlobalContext())));
|
||||||
EXPECT_EQ(PointerType::getUnqual(StructType::get(getGlobalContext(),
|
EXPECT_EQ(PointerType::getUnqual(StructType::get(
|
||||||
TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
|
TypeBuilder<types::i<32>, false>::get(getGlobalContext()),
|
||||||
TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
|
TypeBuilder<types::i<32>*, false>::get(getGlobalContext()),
|
||||||
TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
|
TypeBuilder<types::i<8>*[], false>::get(getGlobalContext()),
|
||||||
|
@@ -214,7 +214,7 @@ static void EmitTypeGenerate(raw_ostream &OS,
|
|||||||
if (ArgTypes.size() == 1)
|
if (ArgTypes.size() == 1)
|
||||||
return EmitTypeGenerate(OS, ArgTypes.front(), ArgNo);
|
return EmitTypeGenerate(OS, ArgTypes.front(), ArgNo);
|
||||||
|
|
||||||
OS << "StructType::get(Context, ";
|
OS << "StructType::get(";
|
||||||
|
|
||||||
for (std::vector<Record*>::const_iterator
|
for (std::vector<Record*>::const_iterator
|
||||||
I = ArgTypes.begin(), E = ArgTypes.end(); I != E; ++I) {
|
I = ArgTypes.begin(), E = ArgTypes.end(); I != E; ++I) {
|
||||||
|
Reference in New Issue
Block a user