Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/target/parsers/cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ namespace parsers {
namespace cpu {

Optional<String> DetectSystemTriple() {
#ifdef TVM_INFO_USE_LLVM
auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
if (pf->defined()) {
return (*pf)();
}
#endif
return {};
}

Expand Down
31 changes: 16 additions & 15 deletions tests/cpp/target_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ TEST(TargetCreation, ProcessStrings) {
ASSERT_EQ(array7[1][1][0], "fred");
}

#ifdef TVM_INFO_USE_LLVM
// Checks that malformed options cause an assertion.
TEST(TargetCreation, LLVMCommandLineParseFatalDashDashDash) {
tvm::codegen::LLVMInstance inst;
Expand Down Expand Up @@ -448,6 +449,21 @@ TEST(TargetCreation, LLVMCommandLineSaveRestore) {
ASSERT_FALSE(info.MatchesGlobalState());
}

TEST(TargetCreation, DetectSystemTriple) {
Map<String, ObjectRef> config = {
{"kind", String("llvm")},
};

Target target = Target(config);
ICHECK_EQ(target->kind, TargetKind::Get("llvm").value());

Optional<String> mtriple = target->GetAttr<String>("mtriple");
auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
ASSERT_TRUE(pf->defined());
}

#endif

TVM_REGISTER_TARGET_KIND("test_external_codegen_0", kDLCUDA)
.set_attr<Bool>(tvm::attr::kIsExternalCodegen, Bool(true));

Expand Down Expand Up @@ -498,21 +514,6 @@ TEST(TargetCreation, DeduplicateKeys) {
ICHECK_EQ(target->GetAttr<String>("device"), "arm_cpu");
}

TEST(TargetCreation, DetectSystemTriple) {
Map<String, ObjectRef> config = {
{"kind", String("llvm")},
};

Target target = Target(config);
ICHECK_EQ(target->kind, TargetKind::Get("llvm").value());

Optional<String> mtriple = target->GetAttr<String>("mtriple");
auto pf = tvm::runtime::Registry::Get("target.llvm_get_system_triple");
if (!pf->defined()) {
GTEST_SKIP() << "LLVM is not available, skipping test";
}
}

TEST(TargetKindRegistry, ListTargetKinds) {
Array<String> names = TargetKindRegEntry::ListTargetKinds();
ICHECK_EQ(names.empty(), false);
Expand Down
5 changes: 4 additions & 1 deletion tests/cpp/tir_scalable_datatype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <llvm/IR/Intrinsics.h>
#include <tvm/runtime/data_type.h>
#include <tvm/tir/builtin.h>
#include <tvm/tir/expr.h>

#ifdef TVM_INFO_USE_LLVM
#include <llvm/IR/Intrinsics.h>
#endif

#include "../../src/script/printer/utils.h"

using ::testing::HasSubstr;
Expand Down