diff options
author | Nicolas Vasilache <ntv@google.com> | 2019-08-19 14:36:49 -0700 |
---|---|---|
committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-08-19 14:37:18 -0700 |
commit | 36f48063ddb9eb43399d604f11653fc4c63894c9 (patch) | |
tree | 12020c98c87b4ca177b60cf35a887af65f1248af /mlir/lib/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.cpp | |
parent | 8165f181d9a1ff503919d3625f6a48955a226b3c (diff) | |
download | bcm5719-llvm-36f48063ddb9eb43399d604f11653fc4c63894c9.tar.gz bcm5719-llvm-36f48063ddb9eb43399d604f11653fc4c63894c9.zip |
Add alignment support to linalg.buffer_alloc
This CL adds an integer attribute to linalg.buffer_alloc and lowering to LLVM.
The alignment is constrained to be a positive power of 2.
Lowering to LLVM produces the pattern:
```
%[[alloc:.*]] = llvm.call @malloc(%[[s]]) : (!llvm.i64) -> !llvm<"i8*">
%[[cast:.*]] = llvm.bitcast %[[alloc]] : !llvm<"i8*"> to !llvm.i64
%[[rem:.*]] = llvm.urem %[[cast]], %[[c16]] : !llvm.i64
%[[drem:.*]] = llvm.sub %[[c16]], %[[rem]] : !llvm.i64
%[[off:.*]] = llvm.urem %[[drem]], %[[c16]] : !llvm.i64
llvm.getelementptr %{{.*}}[%[[off]]] : (!llvm<"i8*">, !llvm.i64) -> !llvm<"i8*">
```
where `ptr` is aligned on `align` by computing the address
`ptr + (align - ptr % align) % align`.
To allow dealloc op to still be able to free memory, additional information is needed in
the buffer type. The buffer type is thus extended with an extra i8* for the base allocation address.
PiperOrigin-RevId: 264244455
Diffstat (limited to 'mlir/lib/Conversion/ControlFlowToCFG/ConvertControlFlowToCFG.cpp')
0 files changed, 0 insertions, 0 deletions