@@ -291,7 +291,7 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
291
291
Variadic<LLVM_ScalarOrVectorOf<AnySignlessInteger>>:$dynamicIndices,
292
292
DenseI32ArrayAttr:$rawConstantIndices,
293
293
TypeAttr:$elem_type,
294
- UnitAttr:$inbounds );
294
+ GEPNoWrapFlagsProp:$gepNoWrapFlags );
295
295
let results = (outs LLVM_ScalarOrVectorOf<LLVM_AnyPointer>:$res);
296
296
let skipDefaultBuilders = 1;
297
297
@@ -303,8 +303,10 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
303
303
as indices. In the case of indexing within a structure, it is required to
304
304
either use constant indices directly, or supply a constant SSA value.
305
305
306
- An optional 'inbounds' attribute specifies the low-level pointer arithmetic
306
+ Optional attributes can be used to specify the low-level pointer arithmetic
307
307
overflow behavior that LLVM uses after lowering the operation to LLVM IR.
308
+ The acceptable attributes could be one of or the combination of 'inbounds',
309
+ 'nusw' or 'nuw'.
308
310
309
311
Examples:
310
312
@@ -323,10 +325,12 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
323
325
324
326
let builders = [
325
327
OpBuilder<(ins "Type":$resultType, "Type":$elementType, "Value":$basePtr,
326
- "ValueRange":$indices, CArg<"bool", "false">:$inbounds,
328
+ "ValueRange":$indices,
329
+ CArg<"GEPNoWrapFlags", "GEPNoWrapFlags::none">:$gepNoWrapFlags,
327
330
CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>,
328
331
OpBuilder<(ins "Type":$resultType, "Type":$elementType, "Value":$basePtr,
329
- "ArrayRef<GEPArg>":$indices, CArg<"bool", "false">:$inbounds,
332
+ "ArrayRef<GEPArg>":$indices,
333
+ CArg<"GEPNoWrapFlags", "GEPNoWrapFlags::none">:$gepNoWrapFlags,
330
334
CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes)>,
331
335
];
332
336
let llvmBuilder = [{
@@ -343,10 +347,13 @@ def LLVM_GEPOp : LLVM_Op<"getelementptr", [Pure,
343
347
}
344
348
Type baseElementType = op.getElemType();
345
349
llvm::Type *elementType = moduleTranslation.convertType(baseElementType);
346
- $res = builder.CreateGEP(elementType, $base, indices, "", $inbounds);
350
+ $res = builder.CreateGEP(elementType, $base, indices, "",
351
+ llvm::GEPNoWrapFlags::fromRaw(
352
+ static_cast<unsigned>(
353
+ op.getGepNoWrapFlags())));
347
354
}];
348
355
let assemblyFormat = [{
349
- (`inbounds` $inbounds ^)?
356
+ ($gepNoWrapFlags ^)?
350
357
$base `[` custom<GEPIndices>($dynamicIndices, $rawConstantIndices) `]` attr-dict
351
358
`:` functional-type(operands, results) `,` $elem_type
352
359
}];
0 commit comments