[flang-commits] [flang] [flang][rfc] Add represention of volatile references (PR #132486)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Mon Mar 31 20:00:10 PDT 2025
================
@@ -361,19 +361,27 @@ def fir_ReferenceType : FIR_Type<"Reference", "ref"> {
let description = [{
The type of a reference to an entity in memory.
+
+ References can be volatile. Any ops taking an operand of a volatile
+ reference must set their memory effects appropriately. Accesses of
+ volatile references are currently modeled as read and write effects
+ to a specific memory resource.
}];
- let parameters = (ins "mlir::Type":$eleTy);
+ let parameters = (ins
+ "mlir::Type":$eleTy,
+ DefaultValuedParameter<"bool", "false">:$isVolatile);
let skipDefaultBuilders = 1;
let builders = [
- TypeBuilderWithInferredContext<(ins "mlir::Type":$elementType), [{
- return Base::get(elementType.getContext(), elementType);
+ TypeBuilderWithInferredContext<(ins "mlir::Type":$elementType, CArg<"bool", "false">:$isVolatile), [{
+ return Base::get(elementType.getContext(), elementType, isVolatile);
}]>,
];
let extraClassDeclaration = [{
+ bool isVolatile() const { return (bool)getIsVolatile(); }
----------------
vzakhari wrote:
If the cast is really needed, I would suggest this:
```suggestion
bool isVolatile() const { return static_cast<bool>(getIsVolatile()); }
```
https://github.com/llvm/llvm-project/pull/132486
More information about the flang-commits
mailing list