Skip to content

Commit

Permalink
Add test target for llvm-cm (#42)
Browse files Browse the repository at this point in the history
This patch sets up a ninja target for testing llvm-cm, akin to the tool
specific test targets in the monorepo. This allows for actually running
the tests. Documentation has been added to the README.
  • Loading branch information
boomanaiden154 authored Feb 3, 2024
1 parent 4ae7b82 commit 94c40d7
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ ninja llvm-granite llvm-cm
Where `LLVM_PROJECT_SRC` is the absolute path to your local llvm repo, and
`GEMATRIA_SRC` the path to this (the gematria) repo.

To run the `llvm-cm` tests, you can run the following target:

```shell
ninja check-llvm-tools-llvm-cm
```

### Platform Support

We develop and test our code on Linux and x86-64, and we test it on Mac OS X and
Expand Down
10 changes: 10 additions & 0 deletions llvm_cm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
add_subdirectory(tools)

configure_lit_site_cfg(
"${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in"
"${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg"
)

add_lit_testsuite(check-llvm-tools-llvm-cm "Running llvm-cm tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS "llvm-cm" "yaml2obj" "not" "FileCheck" "count" "split-file" "llvm-mc"
)
2 changes: 1 addition & 1 deletion llvm_cm/test/X86/bb-frequency.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## LLVM-CM frequency weighting test.
# REQUIRES: x86
# REQUIRES: target-x86_64, native
# RUN: split-file %s %t
# RUN: llvm-mc -o %t.o --filetype=obj -triple=x86_64-unknown-linux-gnu %t/bb-frequency-test.s
# RUN: llvm-cm %t.o --csv=%t/bb-frequency.csv -granite_model=%S/Inputs/gb-token-mit-2022_12_02.tflite -evaluator=granite| FileCheck %t/bb-frequency-test.s
Expand Down
2 changes: 0 additions & 2 deletions llvm_cm/test/X86/lit.local.cfg

This file was deleted.

19 changes: 19 additions & 0 deletions llvm_cm/test/lit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os

import lit.formats

from lit.llvm import llvm_config

config.name = "llvm-cm"
config.test_format = lit.formats.ShTest(execute_external=False)

config.suffixes = [".s", ".test"]

config.test_source_root = os.path.dirname(__file__)
config.test_exec_root = config.obj_root

llvm_config.use_default_substitutions()
config.substitutions.append(("yaml2obj", llvm_config.use_llvm_tool("yaml2obj")))
config.substitutions.append(("llvm-cm", llvm_config.use_llvm_tool("llvm-cm")))
config.substitutions.append(("split-file", llvm_config.use_llvm_tool("split-file")))
config.substitutions.append(("llvm-mc", llvm_config.use_llvm_tool("llvm-mc")))
12 changes: 12 additions & 0 deletions llvm_cm/test/lit.site.cfg.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@LIT_SITE_CFG_IN_HEADER@

config.host_triple = "@LLVM_HOST_TRIPLE@"
config.target_triple = "@LLVM_TARGET_TRIPLE@"
config.src_root = "@LLVM_SOURCE_DIR@"
config.obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")

import lit.llvm
lit.llvm.initialize(lit_config, config)

lit_config.load_config(config, "@LLVM_EXTERNAL_GEMATRIA_SOURCE_DIR@/llvm_cm/test/lit.cfg")

0 comments on commit 94c40d7

Please sign in to comment.