From 4151480afb521c513de0593658904924c4d1a67c Mon Sep 17 00:00:00 2001 From: "Tarn W. Burton" Date: Sat, 28 Sep 2024 14:19:35 -0400 Subject: [PATCH] Add LLVM19 --- include/clasp/clbind/class.h | 6 -- include/clasp/clbind/policies.h | 8 +- include/clasp/gctools/exposeFunctions.h | 2 - include/clasp/gctools/gc_interface.h | 3 - include/clasp/gctools/gcalloc.h | 2 +- include/clasp/gctools/memoryManagement.h | 6 +- include/clasp/llvmo/debugInfoExpose.h | 115 ++++++++++++----------- src/asttooling/astExpose1.cc | 2 + src/koga/units.lisp | 2 +- src/lisp/kernel/cmp/cmpir.lisp | 8 +- src/llvmo/debugInfoExpose.cc | 11 +++ src/llvmo/llvmoExpose.cc | 44 ++++++--- 12 files changed, 117 insertions(+), 92 deletions(-) diff --git a/include/clasp/clbind/class.h b/include/clasp/clbind/class.h index bfe02a3887..8c92a742c7 100644 --- a/include/clasp/clbind/class.h +++ b/include/clasp/clbind/class.h @@ -754,12 +754,6 @@ template st return *this; } - -public: - template - class_& def_property(const std::string& prefix, Getter g, Setter s, const char* docstring = "") { - this->property_impl(prefix, g, s); - } }; } // namespace clbind diff --git a/include/clasp/clbind/policies.h b/include/clasp/clbind/policies.h index e0f47254b5..aed2f0f911 100644 --- a/include/clasp/clbind/policies.h +++ b/include/clasp/clbind/policies.h @@ -130,13 +130,13 @@ template struct policies { bool m_auto_export = true; bool m_setf = false; void describe() { - printf("%s:%d Descibing Policy\n", __FILE__, __LINE__); + fmt::print("{}:{} Descibing Policy\n", __FILE__, __LINE__); if (this->m_lambda_list != "") { - printf("lambda_list = %s\n", this->m_lambda_list.c_str()); + fmt::print("lambda_list = {}\n", this->m_lambda_list); } else { - printf("keyword_list = %s\n", this->keyword_list().c_str()); + fmt::print("keyword_list = {}\n", this->keywordList()); } - printf("Docstring = %s\n", this->m_doc_string.c_str()); + fmt::print("Docstring = {}\n", this->m_doc_string.c_str()); } std::string keywordList() const { if (this->m_keywords.size() == 0) { diff --git a/include/clasp/gctools/exposeFunctions.h b/include/clasp/gctools/exposeFunctions.h index a98eb420db..c951bd0334 100644 --- a/include/clasp/gctools/exposeFunctions.h +++ b/include/clasp/gctools/exposeFunctions.h @@ -90,7 +90,6 @@ class DerivableFrontendActionFactory; #undef DECLARE_FORWARDS #endif #endif -namespace gctools { //////////////////////////////////////////////////////////// // @@ -108,7 +107,6 @@ namespace gctools { #undef GC_STAMP_SELECTORS #endif #endif -}; // namespace gctools extern "C" { bool valid_stamp(gctools::stamp_t kind); diff --git a/include/clasp/gctools/gc_interface.h b/include/clasp/gctools/gc_interface.h index c75b0398f8..0c89f4e453 100644 --- a/include/clasp/gctools/gc_interface.h +++ b/include/clasp/gctools/gc_interface.h @@ -94,8 +94,6 @@ class DerivableFrontendActionFactory; #endif #endif -namespace gctools { - //////////////////////////////////////////////////////////// // // Define the stamps @@ -112,7 +110,6 @@ namespace gctools { #undef GC_STAMP_SELECTORS #endif #endif -}; // namespace gctools extern "C" { bool valid_stamp(gctools::stamp_t kind); diff --git a/include/clasp/gctools/gcalloc.h b/include/clasp/gctools/gcalloc.h index 9af9e1e195..dc5632b243 100644 --- a/include/clasp/gctools/gcalloc.h +++ b/include/clasp/gctools/gcalloc.h @@ -839,7 +839,7 @@ template class GC { size_t capacity = length + 1; size_t size = sizeof_container_with_header(capacity); if (static_container_p) - return GCObjectAllocator::template static_allocate_kind( + return GCObjectAllocator::static_allocate_kind( Header_s::BadgeStampWtagMtag::make_StampWtagMtag(OT::static_ValueStampWtagMtag), size, length, std::forward(args)...); else diff --git a/include/clasp/gctools/memoryManagement.h b/include/clasp/gctools/memoryManagement.h index 106dcbec81..280adb780d 100644 --- a/include/clasp/gctools/memoryManagement.h +++ b/include/clasp/gctools/memoryManagement.h @@ -1030,15 +1030,15 @@ extern size_t global_sizeof_fwd; inline size_t Align(size_t size) { return ((AlignUp(size) >= global_sizeof_fwd) ? AlignUp(size) : global_sizeof_fwd); }; // Manually define these for the sake of As etc. -template <> struct gctools::GCStamp { +template <> struct GCStamp { public: static GCStampEnum const StampWtag = STAMPWTAG_core__Fixnum_dummy_O; }; -template <> struct gctools::GCStamp { +template <> struct GCStamp { public: static GCStampEnum const StampWtag = STAMPWTAG_core__SingleFloat_dummy_O; }; -template <> struct gctools::GCStamp { +template <> struct GCStamp { public: static GCStampEnum const StampWtag = STAMPWTAG_core__Character_dummy_O; }; diff --git a/include/clasp/llvmo/debugInfoExpose.h b/include/clasp/llvmo/debugInfoExpose.h index 4170d78ac3..fced43f4ca 100644 --- a/include/clasp/llvmo/debugInfoExpose.h +++ b/include/clasp/llvmo/debugInfoExpose.h @@ -89,8 +89,8 @@ class DILocation_O : public MDNode_O { } // virtual llvm::DILocation* operator ->() const { return (llvm::DILocation*)(this);}; - DILocation_O() : Base(){}; - virtual ~DILocation_O(){}; + DILocation_O() : Base() {}; + virtual ~DILocation_O() {}; }; // DILocation_O }; // namespace llvmo @@ -98,7 +98,7 @@ namespace translate { template <> struct from_object { typedef llvm::DILocation* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DILocation* ptr) { @@ -125,8 +125,8 @@ class DINode_O : public MDNode_O { } // virtual llvm::DINode* operator ->() const { return (llvm::DINode*)(this);}; - DINode_O() : Base(){}; - virtual ~DINode_O(){}; + DINode_O() : Base() {}; + virtual ~DINode_O() {}; }; // DINode_O }; // namespace llvmo @@ -134,7 +134,7 @@ namespace translate { template <> struct from_object { typedef llvm::DINode* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DINode* ptr) { @@ -161,8 +161,8 @@ class DIExpression_O : public MDNode_O { } // virtual llvm::DIExpression* operator ->() const { return (llvm::DIExpression*)(this);}; - DIExpression_O() : Base(){}; - virtual ~DIExpression_O(){}; + DIExpression_O() : Base() {}; + virtual ~DIExpression_O() {}; }; // DIExpression_O }; // namespace llvmo @@ -170,7 +170,7 @@ namespace translate { template <> struct from_object { typedef llvm::DIExpression* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DIExpression* ptr) { @@ -193,7 +193,7 @@ class DIScope_O : public DINode_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DIScope_O(){}; + DIScope_O() {}; virtual ~DIScope_O() {} }; // DIScope_O }; // namespace llvmo @@ -204,7 +204,7 @@ namespace translate { template <> struct from_object { typedef llvm::DIScope* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DIScope* ptr) { @@ -223,8 +223,8 @@ class DINodeArray_O : public core::CxxObject_O { public: llvm::DINodeArray& get() { return this->_Val._value; }; - DINodeArray_O(const llvm::DINodeArray& v) : _Val(v){}; - DINodeArray_O() : Base(){}; + DINodeArray_O(const llvm::DINodeArray& v) : _Val(v) {}; + DINodeArray_O() : Base() {}; virtual ~DINodeArray_O() {} }; // DINodeArray_O @@ -240,7 +240,7 @@ template <> struct to_object { template <> struct from_object { typedef llvm::DINodeArray DeclareType; DeclareType _v; - from_object(T_P object) : _v(object.nilp() ? nullptr : gc::As(object)->get()){}; + from_object(T_P object) : _v(object.nilp() ? nullptr : gc::As(object)->get()) {}; }; }; // namespace translate @@ -254,8 +254,8 @@ class DITypeRefArray_O : public core::CxxObject_O { public: llvm::DITypeRefArray& get() { return this->_Val._value; }; - DITypeRefArray_O(const llvm::DITypeRefArray& val) : _Val(val){}; - DITypeRefArray_O() : Base(), _Val((llvm::DITypeRefArray)NULL){}; + DITypeRefArray_O(const llvm::DITypeRefArray& val) : _Val(val) {}; + DITypeRefArray_O() : Base(), _Val((llvm::DITypeRefArray)NULL) {}; virtual ~DITypeRefArray_O() {} }; // DITypeRefArray_O }; // namespace llvmo @@ -270,7 +270,7 @@ template <> struct to_object { template <> struct from_object { typedef llvm::DITypeRefArray& DeclareType; DeclareType _v; - from_object(core::T_sp object) : _v(gc::As(object)->get()){}; + from_object(core::T_sp object) : _v(gc::As(object)->get()) {}; }; }; // namespace translate @@ -290,7 +290,7 @@ class DIFile_O : public DIScope_O { } std::string __repr__() const; std::string getPath() const; - DIFile_O(){}; + DIFile_O() {}; virtual ~DIFile_O() {} }; }; // namespace llvmo @@ -301,7 +301,7 @@ namespace translate { template <> struct from_object { typedef llvm::DIFile* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DIFile* ptr) { @@ -324,7 +324,7 @@ class DILocalScope_O : public DIScope_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DILocalScope_O(){}; + DILocalScope_O() {}; virtual ~DILocalScope_O() {} }; }; // namespace llvmo @@ -335,7 +335,7 @@ namespace translate { template <> struct from_object { typedef llvm::DILocalScope* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DILocalScope* ptr) { @@ -360,7 +360,7 @@ class DISubprogram_O : public DILocalScope_O { } std::string __repr__() const; std::string getSubprogram() const; - DISubprogram_O(){}; + DISubprogram_O() {}; virtual ~DISubprogram_O() {} }; }; // namespace llvmo @@ -371,7 +371,7 @@ namespace translate { template <> struct from_object { typedef llvm::DISubprogram* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DISubprogram* ptr) { @@ -394,7 +394,7 @@ class DIType_O : public DIScope_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DIType_O(){}; + DIType_O() {}; virtual ~DIType_O() {} }; }; // namespace llvmo @@ -405,7 +405,7 @@ namespace translate { template <> struct from_object { typedef llvm::DIType* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DIType* ptr) { @@ -428,7 +428,7 @@ class DIBasicType_O : public DIType_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DIBasicType_O(){}; + DIBasicType_O() {}; virtual ~DIBasicType_O() {} }; }; // namespace llvmo @@ -439,7 +439,7 @@ namespace translate { template <> struct from_object { typedef llvm::DIBasicType* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DIBasicType* ptr) { @@ -462,7 +462,7 @@ class DIDerivedType_O : public DIType_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DIDerivedType_O(){}; + DIDerivedType_O() {}; virtual ~DIDerivedType_O() {} }; }; // namespace llvmo @@ -473,7 +473,7 @@ namespace translate { template <> struct from_object { typedef llvm::DIDerivedType* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DIDerivedType* ptr) { @@ -496,7 +496,7 @@ class DICompositeType_O : public DIType_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DICompositeType_O(){}; + DICompositeType_O() {}; virtual ~DICompositeType_O() {} }; }; // namespace llvmo @@ -507,7 +507,7 @@ namespace translate { template <> struct from_object { typedef llvm::DICompositeType* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DICompositeType* ptr) { @@ -530,7 +530,7 @@ class DISubroutineType_O : public DIType_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DISubroutineType_O(){}; + DISubroutineType_O() {}; virtual ~DISubroutineType_O() {} }; }; // namespace llvmo @@ -541,7 +541,7 @@ namespace translate { template <> struct from_object { typedef llvm::DISubroutineType* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DISubroutineType* ptr) { @@ -564,7 +564,7 @@ class DILexicalBlockBase_O : public DILocalScope_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DILexicalBlockBase_O(){}; + DILexicalBlockBase_O() {}; virtual ~DILexicalBlockBase_O() {} }; }; // namespace llvmo @@ -575,7 +575,7 @@ namespace translate { template <> struct from_object { typedef llvm::DILexicalBlockBase* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DILexicalBlockBase* ptr) { @@ -599,7 +599,7 @@ class DILexicalBlock_O : public DILexicalBlockBase_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DILexicalBlock_O(){}; + DILexicalBlock_O() {}; virtual ~DILexicalBlock_O() {} }; }; // namespace llvmo @@ -610,7 +610,7 @@ namespace translate { template <> struct from_object { typedef llvm::DILexicalBlock* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DILexicalBlock* ptr) { @@ -633,7 +633,7 @@ class DICompileUnit_O : public DIScope_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DICompileUnit_O(){}; + DICompileUnit_O() {}; virtual ~DICompileUnit_O() {} }; }; // namespace llvmo @@ -644,7 +644,7 @@ namespace translate { template <> struct from_object { typedef llvm::DICompileUnit* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DICompileUnit* ptr) { @@ -673,6 +673,9 @@ class DIBuilder_O : public core::ExternalObject_O { virtual void* externalObject() const { return this->_ptr; }; PointerToExternalType wrappedPtr() const { return this->_ptr; } + core::T_sp insertDbgValueIntrinsicBasicBlock(llvm::Value* Val, llvm::DILocalVariable* VarInfo, llvm::DIExpression* Expr, + const llvm::DILocation* DL, llvm::BasicBlock* InsertAtEnd); + public: static DIBuilder_sp make(Module_sp context); @@ -683,7 +686,7 @@ class DIBuilder_O : public core::ExternalObject_O { }; DINodeArray_sp getOrCreateArray(core::T_sp elements); DITypeRefArray_sp getOrCreateTypeArray(core::List_sp elements); - DIBuilder_O() : Base(), _ptr(NULL){}; + DIBuilder_O() : Base(), _ptr(NULL) {}; virtual ~DIBuilder_O() { if (_ptr != NULL) { auto ptr = this->_ptr; @@ -706,8 +709,8 @@ namespace translate { template <> struct from_object { typedef llvm::DIBuilder& DeclareType; DeclareType _v; - from_object(T_P object) : _v(*gc::As(object)->wrappedPtr()){}; - ~from_object(){/*non trivial*/}; + from_object(T_P object) : _v(*gc::As(object)->wrappedPtr()) {}; + ~from_object() { /*non trivial*/ }; }; }; // namespace translate @@ -725,7 +728,7 @@ class DIVariable_O : public DINode_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DIVariable_O(){}; + DIVariable_O() {}; virtual ~DIVariable_O() {} }; // DIVariable_O }; // namespace llvmo @@ -736,7 +739,7 @@ namespace translate { template <> struct from_object { typedef llvm::DIVariable* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DIVariable* ptr) { @@ -761,7 +764,7 @@ class DILocalVariable_O : public DIVariable_O { } std::string __repr__() const; std::string getVariableName() const; - DILocalVariable_O(){}; + DILocalVariable_O() {}; virtual ~DILocalVariable_O() {} }; }; // namespace llvmo @@ -772,7 +775,7 @@ namespace translate { template <> struct from_object { typedef llvm::DILocalVariable* DeclareType; DeclareType _v; - from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()){}; + from_object(core::T_sp o) : _v(o.nilp() ? NULL : gc::As(o)->wrappedPtr()) {}; }; template <> struct to_object { static core::T_sp convert(const llvm::DILocalVariable* ptr) { @@ -935,7 +938,7 @@ class DIContext_O : public core::ExternalObject_O { /* delete this->_ptr; */ this->_ptr = ptr; } - DIContext_O() : Base(), _ptr(NULL){}; + DIContext_O() : Base(), _ptr(NULL) {}; ~DIContext_O() { /* delete _ptr;*/ _ptr = NULL; @@ -948,11 +951,11 @@ namespace translate { template <> struct from_object { typedef llvm::DIContext* DeclareType; DeclareType _v; - from_object(T_P object) : _v(gc::As(object)->wrappedPtr()){}; + from_object(T_P object) : _v(gc::As(object)->wrappedPtr()) {}; }; }; // namespace translate - ; +; /* to_object translators */ namespace translate { @@ -982,8 +985,8 @@ class DWARFContext_O : public core::ExternalObject_O { public: static DWARFContext_sp createDWARFContext(ObjectFile_sp); - DWARFContext_O() : Base(), _ptr(NULL){}; - DWARFContext_O(void* b) : Base(), _ptr((PointerToExternalType)b){}; + DWARFContext_O() : Base(), _ptr(NULL) {}; + DWARFContext_O(void* b) : Base(), _ptr((PointerToExternalType)b) {}; ~DWARFContext_O() { /* delete _ptr;*/ _ptr = NULL; @@ -1002,7 +1005,7 @@ namespace translate { template <> struct from_object { typedef llvm::DWARFContext* DeclareType; DeclareType _v; - from_object(T_P object) : _v(gc::As(object)->wrappedPtr()){}; + from_object(T_P object) : _v(gc::As(object)->wrappedPtr()) {}; }; }; // namespace translate @@ -1036,7 +1039,7 @@ class DWARFUnit_O : public core::ExternalObject_O { } public: - DWARFUnit_O() : Base(), _ptr(NULL){}; + DWARFUnit_O() : Base(), _ptr(NULL) {}; ~DWARFUnit_O() { /* delete _ptr;*/ _ptr = NULL; @@ -1050,7 +1053,7 @@ namespace translate { template <> struct from_object { typedef llvm::DWARFUnit* DeclareType; DeclareType _v; - from_object(T_P object) : _v(gc::As(object)->wrappedPtr()){}; + from_object(T_P object) : _v(gc::As(object)->wrappedPtr()) {}; }; }; // namespace translate @@ -1083,7 +1086,7 @@ class LineTable_O : public core::ExternalObject_O { } public: - LineTable_O() : Base(), _ptr(NULL){}; + LineTable_O() : Base(), _ptr(NULL) {}; ~LineTable_O() { /* delete _ptr;*/ _ptr = NULL; @@ -1101,7 +1104,7 @@ namespace translate { template <> struct from_object { typedef const llvm::DWARFDebugLine::LineTable* DeclareType; DeclareType _v; - from_object(T_P object) : _v(gc::As(object)->wrappedPtr()){}; + from_object(T_P object) : _v(gc::As(object)->wrappedPtr()) {}; }; }; // namespace translate diff --git a/src/asttooling/astExpose1.cc b/src/asttooling/astExpose1.cc index 2c00b0583b..8c91cc49f7 100644 --- a/src/asttooling/astExpose1.cc +++ b/src/asttooling/astExpose1.cc @@ -373,7 +373,9 @@ void initialize_astExpose() { scope_Decl_CXXRecord.def("hasDefinition", &clang::CXXRecordDecl::hasDefinition); scope_Decl_CXXRecord.def("isPolymorphic", &clang::CXXRecordDecl::isPolymorphic); scope_Decl_ClassTemplateSpecialization.def("getTemplateArgs", &clang::ClassTemplateSpecializationDecl::getTemplateArgs); + #if LLVM_VERSION_MAJOR < 19 scope_Decl_ClassTemplateSpecialization.def("getTypeAsWritten", &clang::ClassTemplateSpecializationDecl::getTypeAsWritten); + #endif scope_Decl_ClassTemplateSpecialization.def("getPointOfInstantiation", &clang::ClassTemplateSpecializationDecl::getPointOfInstantiation); scope_Decl_ClassTemplateSpecialization.def("getSpecializedTemplate", diff --git a/src/koga/units.lisp b/src/koga/units.lisp index f3880173b7..2e6c2e8ce8 100644 --- a/src/koga/units.lisp +++ b/src/koga/units.lisp @@ -1,7 +1,7 @@ (in-package #:koga) (defparameter +llvm-major-version+ - '(15 . 18) + '(15 . 19) "The required LLVM version.") (defparameter +llvm-config-candidates+ diff --git a/src/lisp/kernel/cmp/cmpir.lisp b/src/lisp/kernel/cmp/cmpir.lisp index c2eeb1c74b..18871ab83d 100644 --- a/src/lisp/kernel/cmp/cmpir.lisp +++ b/src/lisp/kernel/cmp/cmpir.lisp @@ -432,8 +432,8 @@ local-function - the lcl function that all of the xep functions call." (defun irc-sext (val &optional (destty %fixnum%) (label "sext")) (llvm-sys:create-sext *irbuilder* val destty label)) -(defun irc-zext (val &optional (destty %fixnum%) (label "zext") #+llvm18 is-non-neg) - (llvm-sys:create-zext *irbuilder* val destty label #+llvm18 is-non-neg)) +(defun irc-zext (val &optional (destty %fixnum%) (label "zext") #+(or llvm18 llvm19) is-non-neg) + (llvm-sys:create-zext *irbuilder* val destty label #+(or llvm18 llvm19) is-non-neg)) (defun irc-untag-fixnum (t* fixnum-type &optional (label "fixnum")) "Given a T* fixnum llvm::Value, returns a Value of the given type @@ -823,8 +823,8 @@ Otherwise do a variable shift." (llvm-sys:create-unreachable *irbuilder*)) -(defun irc-trunc (value type &optional (label "trunc")) - (llvm-sys:create-trunc *irbuilder* value type label)) +(defun irc-trunc (value type &optional (label "trunc") #+llvm19 is-nuw #+llvm19 is-nsw) + (llvm-sys:create-trunc *irbuilder* value type label #+llvm19 is-nuw #+llvm19 is-nsw)) (defun irc-and (x y &optional (label "and")) diff --git a/src/llvmo/debugInfoExpose.cc b/src/llvmo/debugInfoExpose.cc index c70a2705c9..a9bafc6691 100644 --- a/src/llvmo/debugInfoExpose.cc +++ b/src/llvmo/debugInfoExpose.cc @@ -311,10 +311,21 @@ CL_LISPIFY_NAME(createParameterVariable); CL_EXTERN_DEFMETHOD(DIBuilder_O, &llvm::DIBuilder::createParameterVariable); CL_LISPIFY_NAME(insertDbgValueIntrinsicBasicBlock); +#if LLVM_VERSION_MAJOR < 19 CL_EXTERN_DEFMETHOD(DIBuilder_O, (llvm::Instruction * (llvm::DIBuilder::*)(llvm::Value * Val, llvm::DILocalVariable* VarInfo, llvm::DIExpression* Expr, const llvm::DILocation* DL, llvm::BasicBlock* InsertAtEnd)) & llvm::DIBuilder::insertDbgValueIntrinsic); +#else +CL_DEFMETHOD core::T_sp DIBuilder_O::insertDbgValueIntrinsicBasicBlock(llvm::Value* Val, llvm::DILocalVariable* VarInfo, + llvm::DIExpression* Expr, const llvm::DILocation* DL, + llvm::BasicBlock* InsertAtEnd) { + auto result = _ptr->insertDbgValueIntrinsic(Val, VarInfo, Expr, DL, InsertAtEnd); + if (result.is()) + return translate::to_object::convert(result.get()); + SIMPLE_ERROR("Don't know what to do with returned value from insertDbgValueIntrinsic."); +} +#endif CL_LISPIFY_NAME(finalize); CL_EXTERN_DEFMETHOD(DIBuilder_O, &llvm::DIBuilder::finalize); diff --git a/src/llvmo/llvmoExpose.cc b/src/llvmo/llvmoExpose.cc index 6663262ef3..1193859fa2 100644 --- a/src/llvmo/llvmoExpose.cc +++ b/src/llvmo/llvmoExpose.cc @@ -246,7 +246,7 @@ const char* my_LLVMSymbolLookupCallback(void* DisInfo, uint64_t ReferenceValue, } if (symbol[0] == LITERALS_NAME[0] && strlen(symbol) > strlen(LITERALS_NAME) && strncmp(LITERALS_NAME, symbol + 1, strlen(LITERALS_NAME)) == 0) { - ss << "[" << dbg_safe_repr((uintptr_t) * (uintptr_t*)ReferenceValue) << "]"; + ss << "[" << dbg_safe_repr((uintptr_t)*(uintptr_t*)ReferenceValue) << "]"; } ss << "}"; strcpy(global_LLVMSymbolLookupCallbackBuffer, ss.str().c_str()); @@ -372,7 +372,11 @@ CL_DEFUN Linker_sp Linker_O::make(Module_sp module) { return self; }; -static void expectNoDiags(const llvm::DiagnosticInfo& DI, void* C) { printf("%s:%d Got a diagnostic\n", __FILE__, __LINE__); } +#if LLVM_VERSION_MAJOR < 19 +static void expectNoDiags(const llvm::DiagnosticInfo& DI, void* C) { fmt::print("{}:{} Got a diagnostic\n", __FILE__, __LINE__); } +#else +static void expectNoDiags(const llvm::DiagnosticInfo* DI, void* C) { fmt::print("{}:{} Got a diagnostic\n", __FILE__, __LINE__); } +#endif }; // namespace llvmo namespace { @@ -552,7 +556,7 @@ namespace llvmo { struct Safe_raw_pwrite_stream { llvm::raw_pwrite_stream* ostreamP; - Safe_raw_pwrite_stream() : ostreamP(NULL){}; + Safe_raw_pwrite_stream() : ostreamP(NULL) {}; void set_stream(llvm::raw_pwrite_stream* s) { ostreamP = s; }; llvm::raw_pwrite_stream* get_stream() const { return ostreamP; }; ~Safe_raw_pwrite_stream() { @@ -730,12 +734,12 @@ CL_DEFUN Triple_sp Triple_O::make(const string& triple) { }; CL_PKG_NAME(LlvmoPkg,"triple-normalize"); -CL_EXTERN_DEFUN((std::string(*)(llvm::StringRef str)) & llvm::Triple::normalize); +CL_EXTERN_DEFUN((std::string(*)(llvm::StringRef str))&llvm::Triple::normalize); CL_LISPIFY_NAME(getTriple); CL_EXTERN_DEFMETHOD(Triple_O, &llvm::Triple::getTriple); CL_LISPIFY_NAME(getArchName); -CL_EXTERN_DEFMETHOD(Triple_O, (llvm::StringRef(llvm::Triple::*)() const) & llvm::Triple::getArchName); +CL_EXTERN_DEFMETHOD(Triple_O, (llvm::StringRef(llvm::Triple::*)() const)&llvm::Triple::getArchName); CL_LISPIFY_NAME(getVendorName); CL_EXTERN_DEFMETHOD(Triple_O, &llvm::Triple::getVendorName); CL_LISPIFY_NAME(getOSName); @@ -1403,8 +1407,8 @@ CL_EXTERN_DEFMETHOD(Module_O, (llvm::GlobalVariable * (llvm::Module::*)(llvm::St CL_LISPIFY_NAME(getNamedGlobal); CL_EXTERN_DEFMETHOD(Module_O, (llvm::GlobalVariable * (llvm::Module::*)(llvm::StringRef)) & llvm::Module::getNamedGlobal); CL_LISPIFY_NAME(getOrInsertFunction); -CL_EXTERN_DEFMETHOD(Module_O, (llvm::FunctionCallee(llvm::Module::*)(llvm::StringRef, llvm::FunctionType*)) & - llvm::Module::getOrInsertFunction); +CL_EXTERN_DEFMETHOD(Module_O, (llvm::FunctionCallee(llvm::Module::*)(llvm::StringRef, + llvm::FunctionType*))&llvm::Module::getOrInsertFunction); CL_LISPIFY_NAME(getOrInsertGlobal); CL_EXTERN_DEFMETHOD(Module_O, (llvm::Constant * (llvm::Module::*)(llvm::StringRef, llvm::Type*)) & llvm::Module::getOrInsertGlobal); CL_LISPIFY_NAME(getDataLayoutStr); @@ -1826,9 +1830,11 @@ namespace llvmo { CL_LAMBDA("module type is-constant linkage initializer name &optional (insert-before nil) (thread-local-mode 'llvm-sys:not-thread-local)"); CL_LISPIFY_NAME(make-global-variable); DOCGROUP(clasp); -CL_DEFUN GlobalVariable_sp GlobalVariable_O::make(Module_sp mod, Type_sp type, bool isConstant, llvm::GlobalValue::LinkageTypes linkage, +CL_DEFUN GlobalVariable_sp GlobalVariable_O::make(Module_sp mod, Type_sp type, bool isConstant, + llvm::GlobalValue::LinkageTypes linkage, /*Constant_sp*/ core::T_sp initializer, core::String_sp name, - /*GlobalVariable_sp*/ core::T_sp insertBefore, llvm::GlobalValue::ThreadLocalMode threadLocalMode) { + /*GlobalVariable_sp*/ core::T_sp insertBefore, + llvm::GlobalValue::ThreadLocalMode threadLocalMode) { auto me = gctools::GC::allocate_with_default_constructor(); llvm::Constant* llvm_initializer = NULL; if (initializer.notnilp()) { @@ -1967,7 +1973,7 @@ CL_DEFUN llvm::Instruction* llvm_sys__replace_call(llvm::Function* func, llvm::I // FIXME: Should be made into a generic function or something. CL_LISPIFY_NAME(getCallingConv); -CL_EXTERN_DEFMETHOD(CallBase_O, (llvmo::ClaspCallingConv(llvm::CallBase::*)()) & CallBase_O::ExternalType::getCallingConv); +CL_EXTERN_DEFMETHOD(CallBase_O, (llvmo::ClaspCallingConv(llvm::CallBase::*)())&CallBase_O::ExternalType::getCallingConv); CL_LISPIFY_NAME(setCallingConv); CL_EXTERN_DEFMETHOD(CallBase_O, (void(llvm::CallBase::*)(llvmo::ClaspCallingConv)) & CallBase_O::ExternalType::setCallingConv); @@ -2271,7 +2277,11 @@ CL_DEFUN APInt_sp APInt_O::makeAPIntWidth(core::Integer_sp value, uint width, bo for (size_t i = 0; i < size; ++i) words[i] = limbs[i]; // Note that APInt has its own storage, so it's fine that words expires. +#if LLVM_VERSION_MAJOR < 19 apint = llvm::APInt(width, llvm::makeArrayRef(words, size)); +#else + apint = llvm::APInt(width, llvm::ArrayRef(words, size)); +#endif } self->_value = apint; return self; @@ -2641,10 +2651,17 @@ CL_DEFUN llvm::Value* CreateFNeg(llvmo::IRBuilderBase_O::ExternalType* object, l CL_LISPIFY_NAME(CreateNeg); // CL_EXTERN_DEFMETHOD(IRBuilderBase_O, &IRBuilderBase_O::ExternalType::CreateNeg); DOCGROUP(clasp); +#if LLVM_VERSION_MAJOR < 19 CL_DEFUN llvm::Value* CreateNeg(llvmo::IRBuilderBase_O::ExternalType* object, llvm::Value* V, const llvm::Twine& Name, bool HasNUW, bool HasNSW) { return object->CreateNeg(V, Name, HasNUW, HasNSW); } +#else +CL_DEFUN llvm::Value* CreateNeg(llvmo::IRBuilderBase_O::ExternalType* object, llvm::Value* V, const llvm::Twine& Name, + bool HasNSW) { + return object->CreateNeg(V, Name, HasNSW); +} +#endif CL_LISPIFY_NAME(CreateSRem); // CL_EXTERN_DEFMETHOD(IRBuilderBase_O, &IRBuilderBase_O::ExternalType::CreateSRem); @@ -2804,8 +2821,10 @@ CL_LISPIFY_NAME(CreateFRem); CL_EXTERN_DEFMETHOD(IRBuilderBase_O, &IRBuilderBase_O::ExternalType::CreateFRem); CL_LISPIFY_NAME(CreateNSWNeg); CL_EXTERN_DEFMETHOD(IRBuilderBase_O, &IRBuilderBase_O::ExternalType::CreateNSWNeg); +#if LLVM_VERSION_MAJOR < 19 CL_LISPIFY_NAME(CreateNUWNeg); CL_EXTERN_DEFMETHOD(IRBuilderBase_O, &IRBuilderBase_O::ExternalType::CreateNUWNeg); +#endif CL_LISPIFY_NAME(CreateStore); CL_EXTERN_DEFMETHOD(IRBuilderBase_O, (llvm::StoreInst * (llvm::IRBuilderBase::*)(llvm::Value * Val, llvm::Value* Ptr, bool isVolatile)) & @@ -3311,7 +3330,7 @@ CL_EXTERN_DEFMETHOD(Function_O, &llvm::Function::empty); CL_LISPIFY_NAME(arg_size); CL_EXTERN_DEFMETHOD(Function_O, &llvm::Function::arg_size); CL_LISPIFY_NAME(getCallingConv); -CL_EXTERN_DEFMETHOD(Function_O, (llvmo::ClaspCallingConv(llvm::Function::*)()) & Function_O::ExternalType::getCallingConv); +CL_EXTERN_DEFMETHOD(Function_O, (llvmo::ClaspCallingConv(llvm::Function::*)())&Function_O::ExternalType::getCallingConv); CL_LISPIFY_NAME(setCallingConv); CL_EXTERN_DEFMETHOD(Function_O, (void(llvm::Function::*)(llvmo::ClaspCallingConv)) & Function_O::ExternalType::setCallingConv); CL_LISPIFY_NAME(setDoesNotThrow); @@ -3556,7 +3575,8 @@ namespace llvmo { CL_LAMBDA(context &key elements name is-packed); CL_LISPIFY_NAME(struct-type-create); DOCGROUP(clasp); -CL_DEFUN StructType_sp StructType_O::make(LLVMContext_sp context, core::T_sp elements, llvm::StringRef srname, core::T_sp isPacked) { +CL_DEFUN StructType_sp StructType_O::make(LLVMContext_sp context, core::T_sp elements, llvm::StringRef srname, + core::T_sp isPacked) { llvm::StructType* result = NULL; if (elements.notnilp()) { vector velements;