I am trying to learn more about fixed-point arithmetic via the test case on Clang here:
https://github.com/llvm/llvm-project/blob/main/clang/test/Frontend/fixed_point_div_const.c
https://github.com/llvm/llvm-project/blob/main/clang/test/Frontend/fixed_point_div.c
and I am stuck trying to figure out how to interpret these lines of checks that seem to be happening, for examples:
short _Accum sa_const = 1.0hk / 2.0hk;
// CHECK-DAG: @sa_const = {{.*}}global i16 64, align 2
// CHECK-LABEL: @sdiv_sasasa(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP1:%.*]] = load i16, i16* @sa, align 2
// CHECK-NEXT: [[TMP2:%.*]] = call i16 @llvm.sdiv.fix.i16(i16 [[TMP0]], i16 [[TMP1]], i32 7)
// CHECK-NEXT: store i16 [[TMP2]], i16* @sa, align 2
// CHECK-NEXT: ret void
//
void sdiv_sasasa(void) {
sa = sa / sa;
}
I tried to search around and I arrived at this FileCheck - Flexible pattern matching file verifier — LLVM 16.0.0git documentation, but it wasn’t very clear to me how to interpret these strings in the comment. If I have to take a guess at what was written in the first code block provided here, i.e.:
// CHECK-DAG: @sa_const = {{.*}}global i16 64, align 2
This is checking if the bit patterns of @sa_const
match whatever is describe with {{.*}}global i16 64, align 2
. If that is the case, how should I interpret the string {{.*}}global i16 64, align 2
? My guess is that this is a 16-bit integer that corresponds to value of 64? But then, what does align 2
mean?
Any suggestions/recommendations on how I could search for relevant materials that would help?