Skip to content

Commit

Permalink
[gccjit] clean up and add features from ABI 29
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed Nov 11, 2024
1 parent a4d71f5 commit 8d6fe3e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions include/mlir-gccjit/Conversion/TypeConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
#ifndef MLIR_GCCJIT_CONVERSION_TYPECONVERTER_H
#define MLIR_GCCJIT_CONVERSION_TYPECONVERTER_H

#include <libgccjit.h>
#include <mlir/IR/BuiltinAttributes.h>
#include <mlir/IR/BuiltinTypes.h>
#include <mlir/IR/MLIRContext.h>
#include <mlir/IR/TypeRange.h>
#include <mlir/Transforms/DialectConversion.h>

#include "mlir-gccjit/IR/GCCJITAttrs.h"
#include "mlir-gccjit/IR/GCCJITTypes.h"
#include "mlir/IR/MLIRContext.h"

namespace mlir::gccjit {
class GCCJITTypeConverter : public TypeConverter {
Expand Down
2 changes: 2 additions & 0 deletions include/mlir-gccjit/IR/GCCJITOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def GlobalOp : GCCJIT_Op<"global", [IsolatedFromAbove]> {
}];
let arguments = (ins
GlbKind:$glb_kind,
UnitAttr:$readonly,
SymbolNameAttr:$sym_name,
TypeAttrOf<GCCJIT_LValueType>:$type,
OptionalAttr<StrAttr>:$reg_name,
Expand All @@ -317,6 +318,7 @@ def GlobalOp : GCCJIT_Op<"global", [IsolatedFromAbove]> {
let regions = (region AnyRegion:$body);
let assemblyFormat = [{
$glb_kind
custom<ReadOnlyAttr>($readonly)
$sym_name
oilist (
`reg` `(` qualified($reg_name) `)` |
Expand Down
1 change: 0 additions & 1 deletion src/Conversion/ConvertMemrefToGCCJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <limits>
#include <llvm/Support/Casting.h>
#include <llvm/Support/ErrorHandling.h>
#include <mlir/Dialect/Func/IR/FuncOps.h>
Expand Down
2 changes: 2 additions & 0 deletions src/GCCJITOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ constexpr ParseNamedUnitAttr parseLazyAttribute{"lazy"};
constexpr PrintNamedUnitAttr printLazyAttribute{"lazy"};
constexpr ParseNamedUnitAttr parseWeakAttr{"weak"};
constexpr PrintNamedUnitAttr printWeakAttr{"weak"};
constexpr ParseNamedUnitAttr parseReadOnlyAttr{"readonly"};
constexpr PrintNamedUnitAttr printReadOnlyAttr{"readonly"};

ParseResult
parseAsmOperands(OpAsmParser &parser, ArrayAttr &constrains, ArrayAttr &symbols,
Expand Down
8 changes: 8 additions & 0 deletions src/Translation/TranslateToGCCJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ void GCCJITTranslation::declareAllFunctionAndGlobals() {
gcc_jit_lvalue_add_string_attribute(globalHandle,
GCC_JIT_VARIABLE_ATTRIBUTE_VISIBILITY,
visibility->str().c_str());

if ([[maybe_unused]] auto readonly = global.getReadonly()) {
#ifdef LIBGCCJIT_HAVE_gcc_jit_global_set_readonly
gcc_jit_global_set_readonly(globalHandle);
#else
llvm_unreachable("gcc_jit_global_set_readonly is not available");
#endif
}
if (auto initializer = global.getInitializer()) {
llvm::TypeSwitch<Attribute>(*initializer)
.Case([&](StringAttr attr) {
Expand Down

0 comments on commit 8d6fe3e

Please sign in to comment.