From d6f4bd5a8d321bd29ebe711fa9fa3d1dfa298e26 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Mon, 16 Oct 2023 19:14:24 +0000 Subject: [PATCH] Add README. --- tests/mir-opt/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/mir-opt/README.md b/tests/mir-opt/README.md index 0721d9f7019..cd039bc7e05 100644 --- a/tests/mir-opt/README.md +++ b/tests/mir-opt/README.md @@ -49,3 +49,19 @@ This exists mainly for completeness and is rarely useful. ``` // EMIT_MIR $file_name_of_some_mir_dump.before.mir ``` + +# FileCheck directives + +The LLVM FileCheck tool is used to verify the contents of output MIR against `CHECK` directives +present in the test file. This works on the runtime MIR, generated by `--emit=mir`, and not +on the output of a individual passes. + +To check MIR for function `foo`, start with a `// CHECK-LABEL fn foo(` directive. + +`{{regex}}` syntax allows to match `regex`. + +`[[name:regex]]` syntax allows to bind `name` to a string matching `regex`, and refer to it +as `[[name]]` in later directives, `regex` should be written not to match a leading space. +Use `[[my_local:_.*]]` to name a local, and `[[my_bb:bb.*]]` to name a block. + +Documentation for FileCheck is available here: https://www.llvm.org/docs/CommandGuide/FileCheck.html