ArrayRef<Type> resultTypes,
ArrayRef<NamedAttribute> attributes,
ArrayRef<Block *> successors, unsigned numRegions,
- bool resizableOperandList, MLIRContext *context);
+ bool resizableOperandList);
/// Overload of create that takes an existing NamedAttributeList to avoid
/// unnecessarily uniquing a list of attributes.
ArrayRef<Type> resultTypes,
const NamedAttributeList &attributes,
ArrayRef<Block *> successors, unsigned numRegions,
- bool resizableOperandList, MLIRContext *context);
+ bool resizableOperandList);
/// Create a new Operation from the fields stored in `state`.
static Operation *create(const OperationState &state);
private:
Operation(Location location, OperationName name, unsigned numResults,
unsigned numSuccessors, unsigned numRegions,
- const NamedAttributeList &attributes, MLIRContext *context);
+ const NamedAttributeList &attributes);
// Operations are deleted through the destroy() member because they are
// allocated with malloc.
/// be used as a temporary object on the stack. It is generally unwise to put
/// this in a collection.
struct OperationState {
- MLIRContext *const context;
Location location;
OperationName name;
SmallVector<Value *, 4> operands;
ArrayRef<Type> resultTypes,
ArrayRef<NamedAttribute> attributes,
ArrayRef<Block *> successors, unsigned numRegions,
- bool resizableOperandList, MLIRContext *context) {
+ bool resizableOperandList) {
return create(location, name, operands, resultTypes,
NamedAttributeList(attributes), successors, numRegions,
- resizableOperandList, context);
+ resizableOperandList);
}
/// Create a new Operation from operation state.
unsigned numRegions = state.regions.size();
Operation *op = create(state.location, state.name, state.operands,
state.types, state.attributes, state.successors,
- numRegions, state.resizableOperandList, state.context);
+ numRegions, state.resizableOperandList);
for (unsigned i = 0; i < numRegions; ++i)
if (state.regions[i])
op->getRegion(i).takeBody(*state.regions[i]);
ArrayRef<Type> resultTypes,
const NamedAttributeList &attributes,
ArrayRef<Block *> successors, unsigned numRegions,
- bool resizableOperandList, MLIRContext *context) {
+ bool resizableOperandList) {
unsigned numSuccessors = successors.size();
// Input operands are nullptr-separated for each successor, the null operands
void *rawMem = malloc(byteSize);
// Create the new Operation.
- auto op =
- ::new (rawMem) Operation(location, name, resultTypes.size(),
- numSuccessors, numRegions, attributes, context);
+ auto op = ::new (rawMem) Operation(location, name, resultTypes.size(),
+ numSuccessors, numRegions, attributes);
assert((numSuccessors == 0 || !op->isKnownNonTerminator()) &&
"unexpected successors in a non-terminator operation");
Operation::Operation(Location location, OperationName name, unsigned numResults,
unsigned numSuccessors, unsigned numRegions,
- const NamedAttributeList &attributes, MLIRContext *context)
+ const NamedAttributeList &attributes)
: location(location), numResults(numResults), numSuccs(numSuccessors),
numRegions(numRegions), name(name), attrs(attributes) {}
SmallVector<Type, 8> resultTypes(getResultTypes());
unsigned numRegions = getNumRegions();
- auto *newOp = Operation::create(getLoc(), getName(), operands, resultTypes,
- attrs, successors, numRegions,
- hasResizableOperandsList(), getContext());
+ auto *newOp =
+ Operation::create(getLoc(), getName(), operands, resultTypes, attrs,
+ successors, numRegions, hasResizableOperandsList());
// Remember the mapping of any results.
for (unsigned i = 0, e = getNumResults(); i != e; ++i)
//===----------------------------------------------------------------------===//
OperationState::OperationState(Location location, StringRef name)
- : context(location->getContext()), location(location),
- name(name, location->getContext()) {}
+ : location(location), name(name, location->getContext()) {}
OperationState::OperationState(Location location, OperationName name)
- : context(location->getContext()), location(location), name(name) {}
+ : location(location), name(name) {}
OperationState::OperationState(Location location, StringRef name,
ArrayRef<Value *> operands, ArrayRef<Type> types,
ArrayRef<Block *> successors,
MutableArrayRef<std::unique_ptr<Region>> regions,
bool resizableOperandList)
- : context(location->getContext()), location(location),
- name(name, location->getContext()),
+ : location(location), name(name, location->getContext()),
operands(operands.begin(), operands.end()),
types(types.begin(), types.end()),
attributes(attributes.begin(), attributes.end()),
successors(successors.begin(), successors.end()) {
- for (std::unique_ptr<Region> &r : regions) {
+ for (std::unique_ptr<Region> &r : regions)
this->regions.push_back(std::move(r));
- }
}
Region *OperationState::addRegion() {
auto *op = Operation::create(
getEncodedSourceLocation(loc), name, /*operands=*/{}, type,
/*attributes=*/llvm::None, /*successors=*/{}, /*numRegions=*/0,
- /*resizableOperandList=*/false, getContext());
+ /*resizableOperandList=*/false);
forwardRefPlaceholders[op->getResult(0)] = loc;
return op->getResult(0);
}
/// given input and result types.
Operation *ArgConverter::createCast(ArrayRef<Value *> inputs, Type outputType) {
return Operation::create(loc, castOpName, inputs, outputType, llvm::None,
- llvm::None, 0, false, outputType.getContext());
+ llvm::None, 0, false);
}
//===----------------------------------------------------------------------===//
let printer = [{ *p << getAttr("attr"); }];
let parser = [{
Attribute attr;
- Type stringType = OpaqueType::get(Identifier::get("foo", result->context),
- "string", result->context);
+ Type stringType = OpaqueType::get(Identifier::get("foo",
+ result->getContext()), "string",
+ result->getContext());
return parser->parseAttribute(attr, stringType, "attr", result->attributes);
}];
}
ArrayRef<Type> resultTypes = llvm::None) {
return Operation::create(
UnknownLoc::get(context), OperationName("foo.bar", context), operands,
- resultTypes, llvm::None, llvm::None, 0, resizableOperands, context);
+ resultTypes, llvm::None, llvm::None, 0, resizableOperands);
}
TEST(OperandStorageTest, NonResizable) {