2009-06-30 08:48:55 +08:00
|
|
|
//===-- LLVMContext.cpp - Implement LLVMContext -----------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-07-01 01:06:46 +08:00
|
|
|
//
|
|
|
|
// This file implements LLVMContext, as a wrapper around the opaque
|
|
|
|
// class LLVMContextImpl.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-30 08:48:55 +08:00
|
|
|
|
|
|
|
#include "llvm/LLVMContext.h"
|
|
|
|
#include "llvm/Constants.h"
|
2009-07-01 01:50:28 +08:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2009-07-01 07:39:59 +08:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2009-06-30 08:48:55 +08:00
|
|
|
#include "LLVMContextImpl.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2009-07-01 07:39:59 +08:00
|
|
|
static ManagedStatic<LLVMContext> GlobalContext;
|
|
|
|
|
2009-07-02 07:13:44 +08:00
|
|
|
LLVMContext& llvm::getGlobalContext() {
|
2009-07-02 05:22:36 +08:00
|
|
|
return *GlobalContext;
|
2009-07-01 07:39:59 +08:00
|
|
|
}
|
|
|
|
|
2009-06-30 08:48:55 +08:00
|
|
|
LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }
|
|
|
|
LLVMContext::~LLVMContext() { delete pImpl; }
|
|
|
|
|
|
|
|
// ConstantInt accessors.
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantInt* LLVMContext::getConstantIntTrue() {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantInt::getTrue();
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantInt* LLVMContext::getConstantIntFalse() {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantInt::getFalse();
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstantInt* LLVMContext::getConstantInt(const IntegerType* Ty, uint64_t V,
|
2009-07-02 06:33:26 +08:00
|
|
|
bool isSigned) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantInt::get(Ty, V, isSigned);
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstantInt* LLVMContext::getConstantIntSigned(const IntegerType* Ty,
|
2009-07-02 06:33:26 +08:00
|
|
|
int64_t V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantInt::getSigned(Ty, V);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantInt* LLVMContext::getConstantInt(const APInt& V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantInt::get(V);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantInt::get(Ty, V);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantInt* LLVMContext::getAllOnesConstantInt(const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantInt::getAllOnesValue(Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConstantPointerNull accessors.
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantPointerNull* LLVMContext::getConstantPointerNull(const PointerType* T) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantPointerNull::get(T);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConstantStruct accessors.
|
|
|
|
Constant* LLVMContext::getConstantStruct(const StructType* T,
|
2009-07-02 06:33:26 +08:00
|
|
|
const std::vector<Constant*>& V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantStruct::get(T, V);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantStruct(const std::vector<Constant*>& V,
|
2009-07-02 06:33:26 +08:00
|
|
|
bool Packed) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantStruct::get(V, Packed);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantStruct(Constant* const *Vals,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumVals, bool Packed) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantStruct::get(Vals, NumVals, Packed);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConstantAggregateZero accessors.
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantAggregateZero* LLVMContext::getConstantAggregateZero(const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantAggregateZero::get(Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConstantArray accessors.
|
|
|
|
Constant* LLVMContext::getConstantArray(const ArrayType* T,
|
2009-07-02 06:33:26 +08:00
|
|
|
const std::vector<Constant*>& V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantArray::get(T, V);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantArray(const ArrayType* T,
|
|
|
|
Constant* const* Vals,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumVals) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantArray::get(T, Vals, NumVals);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantArray(const std::string& Initializer,
|
2009-07-02 06:33:26 +08:00
|
|
|
bool AddNull) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantArray::get(Initializer, AddNull);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConstantExpr accessors.
|
|
|
|
Constant* LLVMContext::getConstantExpr(unsigned Opcode, Constant* C1,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::get(Opcode, C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprTrunc(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getTrunc(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprSExt(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getSExt(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprZExt(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getZExt(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFPTrunc(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFPTrunc(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFPExtend(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFPExtend(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprUIToFP(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getUIToFP(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprSIToFP(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getSIToFP(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFPToUI(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFPToUI(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFPToSI(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFPToSI(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprPtrToInt(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getPtrToInt(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprIntToPtr(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getIntToPtr(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprBitCast(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getBitCast(C, Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprCast(unsigned ops, Constant* C,
|
2009-07-02 06:33:26 +08:00
|
|
|
const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getCast(ops, C, Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprZExtOrBitCast(Constant* C,
|
2009-07-02 06:33:26 +08:00
|
|
|
const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getZExtOrBitCast(C, Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprSExtOrBitCast(Constant* C,
|
2009-07-02 06:33:26 +08:00
|
|
|
const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getSExtOrBitCast(C, Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprTruncOrBitCast(Constant* C,
|
2009-07-02 06:33:26 +08:00
|
|
|
const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getTruncOrBitCast(C, Ty);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprPointerCast(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getPointerCast(C, Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprIntegerCast(Constant* C, const Type* Ty,
|
2009-07-02 06:33:26 +08:00
|
|
|
bool isSigned) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getIntegerCast(C, Ty, isSigned);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFPCast(Constant* C, const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFPCast(C, Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprSelect(Constant* C, Constant* V1,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* V2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getSelect(C, V1, V2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprAlignOf(const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getAlignOf(Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprCompare(unsigned short pred,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getCompare(pred, C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprNeg(Constant* C) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getNeg(C);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFNeg(Constant* C) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFNeg(C);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprNot(Constant* C) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getNot(C);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getAdd(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFAdd(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFAdd(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprSub(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getSub(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFSub(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFSub(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprMul(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getMul(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFMul(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFMul(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprUDiv(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getUDiv(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprSDiv(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getSDiv(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFDiv(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFDiv(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprURem(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getURem(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprSRem(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getSRem(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprFRem(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFRem(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprAnd(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getAnd(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprOr(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getOr(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprXor(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getXor(C1, C2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprICmp(unsigned short pred, Constant* LHS,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* RHS) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getICmp(pred, LHS, RHS);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprFCmp(unsigned short pred, Constant* LHS,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* RHS) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getFCmp(pred, LHS, RHS);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprVICmp(unsigned short pred, Constant* LHS,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* RHS) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getVICmp(pred, LHS, RHS);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprVFCmp(unsigned short pred, Constant* LHS,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* RHS) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getVFCmp(pred, LHS, RHS);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getShl(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprLShr(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getLShr(C1, C2);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantExprAShr(Constant* C1, Constant* C2) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getAShr(C1, C2);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C,
|
|
|
|
Constant* const* IdxList,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumIdx) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C,
|
|
|
|
Value* const* IdxList,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumIdx) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getGetElementPtr(C, IdxList, NumIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprExtractElement(Constant* Vec,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* Idx) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getExtractElement(Vec, Idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprInsertElement(Constant* Vec,
|
|
|
|
Constant* Elt,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* Idx) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getInsertElement(Vec, Elt, Idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprShuffleVector(Constant* V1, Constant* V2,
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* Mask) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getShuffleVector(V1, V2, Mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprExtractValue(Constant* Agg,
|
|
|
|
const unsigned* IdxList,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumIdx) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getExtractValue(Agg, IdxList, NumIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantExprInsertValue(Constant* Agg, Constant* Val,
|
|
|
|
const unsigned* IdxList,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumIdx) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getInsertValue(Agg, Val, IdxList, NumIdx);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getZeroValueForNegation(const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantExpr::getZeroValueForNegationExpr(Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConstantFP accessors.
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantFP* LLVMContext::getConstantFP(const APFloat& V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantFP::get(V);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantFP(const Type* Ty, double V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantFP::get(Ty, V);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantFP* LLVMContext::getConstantFPNegativeZero(const Type* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantFP::getNegativeZero(Ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConstantVector accessors.
|
|
|
|
Constant* LLVMContext::getConstantVector(const VectorType* T,
|
2009-07-02 06:33:26 +08:00
|
|
|
const std::vector<Constant*>& V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantVector::get(T, V);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
Constant* LLVMContext::getConstantVector(const std::vector<Constant*>& V) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantVector::get(V);
|
|
|
|
}
|
|
|
|
|
|
|
|
Constant* LLVMContext::getConstantVector(Constant* const* Vals,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumVals) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantVector::get(Vals, NumVals);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
ConstantVector* LLVMContext::getConstantVectorAllOnes(const VectorType* Ty) {
|
2009-06-30 08:48:55 +08:00
|
|
|
return ConstantVector::getAllOnesValue(Ty);
|
|
|
|
}
|
2009-07-01 01:50:28 +08:00
|
|
|
|
|
|
|
// FunctionType accessors
|
|
|
|
FunctionType* LLVMContext::getFunctionType(const Type* Result,
|
|
|
|
const std::vector<const Type*>& Params,
|
2009-07-02 06:33:26 +08:00
|
|
|
bool isVarArg) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return FunctionType::get(Result, Params, isVarArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// IntegerType accessors
|
2009-07-02 06:33:26 +08:00
|
|
|
const IntegerType* LLVMContext::getIntegerType(unsigned NumBits) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return IntegerType::get(NumBits);
|
|
|
|
}
|
|
|
|
|
|
|
|
// OpaqueType accessors
|
2009-07-02 06:33:26 +08:00
|
|
|
OpaqueType* LLVMContext::getOpaqueType() {
|
2009-07-01 01:50:28 +08:00
|
|
|
return OpaqueType::get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// StructType accessors
|
|
|
|
StructType* LLVMContext::getStructType(const std::vector<const Type*>& Params,
|
2009-07-02 06:33:26 +08:00
|
|
|
bool isPacked) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return StructType::get(Params, isPacked);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ArrayType accessors
|
|
|
|
ArrayType* LLVMContext::getArrayType(const Type* ElementType,
|
2009-07-02 06:33:26 +08:00
|
|
|
uint64_t NumElements) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return ArrayType::get(ElementType, NumElements);
|
|
|
|
}
|
|
|
|
|
|
|
|
// PointerType accessors
|
|
|
|
PointerType* LLVMContext::getPointerType(const Type* ElementType,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned AddressSpace) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return PointerType::get(ElementType, AddressSpace);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
PointerType* LLVMContext::getPointerTypeUnqualified(const Type* ElementType) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return PointerType::getUnqual(ElementType);
|
|
|
|
}
|
|
|
|
|
|
|
|
// VectorType accessors
|
|
|
|
VectorType* LLVMContext::getVectorType(const Type* ElementType,
|
2009-07-02 06:33:26 +08:00
|
|
|
unsigned NumElements) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return VectorType::get(ElementType, NumElements);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
VectorType* LLVMContext::getVectorTypeInteger(const VectorType* VTy) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return VectorType::getInteger(VTy);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
VectorType* LLVMContext::getVectorTypeExtendedElement(const VectorType* VTy) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return VectorType::getExtendedElementVectorType(VTy);
|
|
|
|
}
|
|
|
|
|
2009-07-02 06:33:26 +08:00
|
|
|
VectorType* LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) {
|
2009-07-01 01:50:28 +08:00
|
|
|
return VectorType::getTruncatedElementVectorType(VTy);
|
|
|
|
}
|