summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp')
-rw-r--r--mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 6cf975bcce2..7273d3dfd7b 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -76,7 +76,7 @@ private:
/// `value` is an SSA-use. Return the remapped version of `value` or a
/// placeholder that will be remapped later if this is an instruction that
/// has not yet been visited.
- Value *processValue(llvm::Value *value);
+ ValuePtr processValue(llvm::Value *value);
/// Create the most accurate Location possible using a llvm::DebugLoc and
/// possibly an llvm::Instruction to narrow the Location if debug information
/// is unavailable.
@@ -85,14 +85,14 @@ private:
/// `br` branches to `target`. Return the block arguments to attach to the
/// generated branch op. These should be in the same order as the PHIs in
/// `target`.
- SmallVector<Value *, 4> processBranchArgs(llvm::BranchInst *br,
- llvm::BasicBlock *target);
+ SmallVector<ValuePtr, 4> processBranchArgs(llvm::BranchInst *br,
+ llvm::BasicBlock *target);
/// Return `value` as an attribute to attach to a GlobalOp.
Attribute getConstantAsAttr(llvm::Constant *value);
/// Return `c` as an MLIR Value. This could either be a ConstantOp, or
/// an expanded sequence of ops in the current function's entry block (for
/// ConstantExprs or ConstantGEPs).
- Value *processConstant(llvm::Constant *c);
+ ValuePtr processConstant(llvm::Constant *c);
/// The current builder, pointing at where the next Instruction should be
/// generated.
@@ -120,7 +120,7 @@ private:
/// Remapped blocks, for the current function.
DenseMap<llvm::BasicBlock *, Block *> blocks;
/// Remapped values. These are function-local.
- DenseMap<llvm::Value *, Value *> instMap;
+ DenseMap<llvm::Value *, ValuePtr> instMap;
/// Instructions that had not been defined when first encountered as a use.
/// Maps to the dummy Operation that was created in processValue().
DenseMap<llvm::Value *, Operation *> unknownInstMap;
@@ -263,13 +263,13 @@ GlobalOp Importer::processGlobal(llvm::GlobalVariable *GV) {
Region &r = op.getInitializerRegion();
currentEntryBlock = b.createBlock(&r);
b.setInsertionPoint(currentEntryBlock, currentEntryBlock->begin());
- Value *v = processConstant(GV->getInitializer());
- b.create<ReturnOp>(op.getLoc(), ArrayRef<Value *>({v}));
+ ValuePtr v = processConstant(GV->getInitializer());
+ b.create<ReturnOp>(op.getLoc(), ArrayRef<ValuePtr>({v}));
}
return globals[GV] = op;
}
-Value *Importer::processConstant(llvm::Constant *c) {
+ValuePtr Importer::processConstant(llvm::Constant *c) {
if (Attribute attr = getConstantAsAttr(c)) {
// These constants can be represented as attributes.
OpBuilder b(currentEntryBlock, currentEntryBlock->begin());
@@ -298,7 +298,7 @@ Value *Importer::processConstant(llvm::Constant *c) {
return nullptr;
}
-Value *Importer::processValue(llvm::Value *value) {
+ValuePtr Importer::processValue(llvm::Value *value) {
auto it = instMap.find(value);
if (it != instMap.end())
return it->second;
@@ -407,9 +407,9 @@ static ICmpPredicate getICmpPredicate(llvm::CmpInst::Predicate p) {
// `br` branches to `target`. Return the branch arguments to `br`, in the
// same order of the PHIs in `target`.
-SmallVector<Value *, 4> Importer::processBranchArgs(llvm::BranchInst *br,
- llvm::BasicBlock *target) {
- SmallVector<Value *, 4> v;
+SmallVector<ValuePtr, 4> Importer::processBranchArgs(llvm::BranchInst *br,
+ llvm::BasicBlock *target) {
+ SmallVector<ValuePtr, 4> v;
for (auto inst = target->begin(); isa<llvm::PHINode>(inst); ++inst) {
auto *PN = cast<llvm::PHINode>(&*inst);
v.push_back(processValue(PN->getIncomingValueForBlock(br->getParent())));
@@ -421,7 +421,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
// FIXME: Support uses of SubtargetData. Currently inbounds GEPs, fast-math
// flags and call / operand attributes are not supported.
Location loc = processDebugLoc(inst->getDebugLoc(), inst);
- Value *&v = instMap[inst];
+ ValuePtr &v = instMap[inst];
assert(!v && "processInstruction must be called only once per instruction!");
switch (inst->getOpcode()) {
default:
@@ -462,7 +462,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
case llvm::Instruction::AddrSpaceCast:
case llvm::Instruction::BitCast: {
OperationState state(loc, opcMap.lookup(inst->getOpcode()));
- SmallVector<Value *, 4> ops;
+ SmallVector<ValuePtr, 4> ops;
ops.reserve(inst->getNumOperands());
for (auto *op : inst->operand_values())
ops.push_back(processValue(op));
@@ -484,7 +484,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
auto *brInst = cast<llvm::BranchInst>(inst);
OperationState state(loc,
brInst->isConditional() ? "llvm.cond_br" : "llvm.br");
- SmallVector<Value *, 4> ops;
+ SmallVector<ValuePtr, 4> ops;
if (brInst->isConditional())
ops.push_back(processValue(brInst->getCondition()));
state.addOperands(ops);
@@ -500,7 +500,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
}
case llvm::Instruction::Call: {
llvm::CallInst *ci = cast<llvm::CallInst>(inst);
- SmallVector<Value *, 4> ops;
+ SmallVector<ValuePtr, 4> ops;
ops.reserve(inst->getNumOperands());
for (auto &op : ci->arg_operands())
ops.push_back(processValue(op.get()));
@@ -523,7 +523,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
case llvm::Instruction::GetElementPtr: {
// FIXME: Support inbounds GEPs.
llvm::GetElementPtrInst *gep = cast<llvm::GetElementPtrInst>(inst);
- SmallVector<Value *, 4> ops;
+ SmallVector<ValuePtr, 4> ops;
for (auto *op : gep->operand_values())
ops.push_back(processValue(op));
v = b.create<GEPOp>(loc, processType(inst->getType()), ops,
@@ -565,8 +565,8 @@ LogicalResult Importer::processFunction(llvm::Function *f) {
// any unknown uses we encountered are remapped.
for (auto &llvmAndUnknown : unknownInstMap) {
assert(instMap.count(llvmAndUnknown.first));
- Value *newValue = instMap[llvmAndUnknown.first];
- Value *oldValue = llvmAndUnknown.second->getResult(0);
+ ValuePtr newValue = instMap[llvmAndUnknown.first];
+ ValuePtr oldValue = llvmAndUnknown.second->getResult(0);
oldValue->replaceAllUsesWith(newValue);
llvmAndUnknown.second->erase();
}
OpenPOWER on IntegriCloud