From f2ed69af9e5bc1b998bb4e831a1bc5964e76f609 Mon Sep 17 00:00:00 2001 From: "A. R. Shajii" Date: Sat, 19 Feb 2022 14:30:44 -0500 Subject: [PATCH 1/4] Update dict attribute --- codon/sir/attribute.cpp | 15 +++++++++++---- codon/sir/attribute.h | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/codon/sir/attribute.cpp b/codon/sir/attribute.cpp index 445ef10a..45433a54 100644 --- a/codon/sir/attribute.cpp +++ b/codon/sir/attribute.cpp @@ -120,7 +120,8 @@ const std::string DictLiteralAttribute::AttributeName = "dictLiteralAttribute"; std::unique_ptr DictLiteralAttribute::clone(util::CloneVisitor &cv) const { std::vector elementsCloned; for (auto &val : elements) - elementsCloned.push_back({cv.clone(val.key), cv.clone(val.value)}); + elementsCloned.push_back( + {cv.clone(val.key), val.value ? cv.clone(val.value) : nullptr}); return std::make_unique(elementsCloned); } @@ -128,14 +129,20 @@ std::unique_ptr DictLiteralAttribute::forceClone(util::CloneVisitor &cv) const { std::vector elementsCloned; for (auto &val : elements) - elementsCloned.push_back({cv.forceClone(val.key), cv.forceClone(val.value)}); + elementsCloned.push_back( + {cv.forceClone(val.key), val.value ? cv.forceClone(val.value) : nullptr}); return std::make_unique(elementsCloned); } std::ostream &DictLiteralAttribute::doFormat(std::ostream &os) const { std::vector strings; - for (auto &val : elements) - strings.push_back(fmt::format(FMT_STRING("{}:{}"), *val.key, *val.value)); + for (auto &val : elements) { + if (val.value) { + strings.push_back(fmt::format(FMT_STRING("{}:{}"), *val.key, *val.value)); + } else { + strings.push_back(fmt::format(FMT_STRING("**{}"), *val.key)); + } + } fmt::print(os, FMT_STRING("dict([{}])"), fmt::join(strings.begin(), strings.end(), ",")); return os; diff --git a/codon/sir/attribute.h b/codon/sir/attribute.h index 2c79ed81..f86edfa5 100644 --- a/codon/sir/attribute.h +++ b/codon/sir/attribute.h @@ -177,7 +177,9 @@ private: /// Attribute attached to IR structures corresponding to dict literals struct DictLiteralAttribute : public Attribute { struct KeyValuePair { + /// the key in the literal Value *key; + /// the value in the literal, or null if key is being star-unpacked Value *value; }; From 685c42981d309e4859aa078055208981c0d46f63 Mon Sep 17 00:00:00 2001 From: "A. R. Shajii" Date: Tue, 22 Feb 2022 10:16:30 -0500 Subject: [PATCH 2/4] Remove invalid check --- codon/sir/llvm/llvisitor.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/codon/sir/llvm/llvisitor.cpp b/codon/sir/llvm/llvisitor.cpp index cbc431fd..cd0cf2ee 100644 --- a/codon/sir/llvm/llvisitor.cpp +++ b/codon/sir/llvm/llvisitor.cpp @@ -874,8 +874,6 @@ void LLVMVisitor::visit(const InternalFunc *x) { } } - if (!result) - internalFuncMatchesIgnoreArgs("__new__", x); seqassert(result, "internal function {} not found", *x); B->CreateRet(result); } From 4452367c1fb32acb8ec00b34d08f140a066a09c9 Mon Sep 17 00:00:00 2001 From: "A. R. Shajii" Date: Tue, 22 Feb 2022 10:17:50 -0500 Subject: [PATCH 3/4] Update OpenMP --- cmake/deps.cmake | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/cmake/deps.cmake b/cmake/deps.cmake index ccbf1abd..aa093bbe 100644 --- a/cmake/deps.cmake +++ b/cmake/deps.cmake @@ -66,13 +66,11 @@ if(bdwgc_ADDED) endif() CPMAddPackage( - GITHUB_REPOSITORY "llvm-mirror/openmp" - VERSION 9.0 - GIT_TAG release_90 - # GITHUB_REPOSITORY "exaloop/openmp" - # VERSION 12.0.1 - # GIT_TAG v12.0.1 - OPTIONS "OPENMP_ENABLE_LIBOMPTARGET OFF" + NAME openmp + GITHUB_REPOSITORY "exaloop/openmp" + VERSION 13.0.0-fb9fc3c + OPTIONS "CMAKE_BUILD_TYPE Release" + "OPENMP_ENABLE_LIBOMPTARGET OFF" "OPENMP_STANDALONE_BUILD ON") CPMAddPackage( From bba16437c707ed334321d4c7d0912d2b8dd1865e Mon Sep 17 00:00:00 2001 From: "A. R. Shajii" Date: Wed, 23 Feb 2022 16:20:33 -0500 Subject: [PATCH 4/4] Store function name in PartialFunctionAttribute --- codon/sir/attribute.cpp | 8 +++----- codon/sir/attribute.h | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/codon/sir/attribute.cpp b/codon/sir/attribute.cpp index 45433a54..075d6b4a 100644 --- a/codon/sir/attribute.cpp +++ b/codon/sir/attribute.cpp @@ -155,8 +155,7 @@ PartialFunctionAttribute::clone(util::CloneVisitor &cv) const { std::vector argsCloned; for (auto *val : args) argsCloned.push_back(cv.clone(val)); - return std::make_unique(cast(cv.clone(func)), - argsCloned); + return std::make_unique(name, argsCloned); } std::unique_ptr @@ -164,15 +163,14 @@ PartialFunctionAttribute::forceClone(util::CloneVisitor &cv) const { std::vector argsCloned; for (auto *val : args) argsCloned.push_back(cv.forceClone(val)); - return std::make_unique(cast(cv.forceClone(func)), - argsCloned); + return std::make_unique(name, argsCloned); } std::ostream &PartialFunctionAttribute::doFormat(std::ostream &os) const { std::vector strings; for (auto *val : args) strings.push_back(val ? fmt::format(FMT_STRING("{}"), *val) : "..."); - fmt::print(os, FMT_STRING("{}({})"), func->getName(), + fmt::print(os, FMT_STRING("{}({})"), name, fmt::join(strings.begin(), strings.end(), ",")); return os; } diff --git a/codon/sir/attribute.h b/codon/sir/attribute.h index f86edfa5..eb2e945f 100644 --- a/codon/sir/attribute.h +++ b/codon/sir/attribute.h @@ -202,15 +202,15 @@ private: struct PartialFunctionAttribute : public Attribute { static const std::string AttributeName; - /// function being called - Func *func; + /// base name of the function being used in the partial + std::string name; /// partial arguments, or null if none /// e.g. "f(a, ..., b)" has elements [a, null, b] std::vector args; - PartialFunctionAttribute(Func *func, std::vector args) - : func(func), args(std::move(args)) {} + PartialFunctionAttribute(const std::string &name, std::vector args) + : name(name), args(std::move(args)) {} std::unique_ptr clone(util::CloneVisitor &cv) const override; std::unique_ptr forceClone(util::CloneVisitor &cv) const override;