-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CIRGen][Builtin] Support __builtin_elementwise_abs and extend A…
…bsOp to take vector input (#1099) Extend AbsOp to take vector of int input. With it, we can support __builtin_elementwise_abs. We should in the next PR extend FpUnaryOps to support vector type input so we won't have blocker to implement all elementwise builtins completely. Now just temporarily have missingFeature `fpUnaryOPsSupportVectorType`. Currently, int type UnaryOp support vector type. FYI: [clang's documentation about elementwise builtins](https://clang.llvm.org/docs/LanguageExtensions.html#vector-builtins)
- Loading branch information
Showing
7 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// RUN: %clang_cc1 -triple aarch64-none-linux-android24 -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s | ||
// RUN: %clang_cc1 -triple aarch64-none-linux-android24 -fclangir \ | ||
// RUN: -emit-llvm %s -o %t.ll | ||
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s | ||
|
||
typedef int vint4 __attribute__((ext_vector_type(4))); | ||
|
||
void test_builtin_elementwise_abs(vint4 vi4, int i, float f, double d) { | ||
// CIR-LABEL: test_builtin_elementwise_abs | ||
// LLVM-LABEL: test_builtin_elementwise_abs | ||
// CIR: {{%.*}} = cir.fabs {{%.*}} : !cir.float | ||
// LLVM: {{%.*}} = call float @llvm.fabs.f32(float {{%.*}}) | ||
f = __builtin_elementwise_abs(f); | ||
|
||
// CIR: {{%.*}} = cir.fabs {{%.*}} : !cir.double | ||
// LLVM: {{%.*}} = call double @llvm.fabs.f64(double {{%.*}}) | ||
d = __builtin_elementwise_abs(d); | ||
|
||
// CIR: {{%.*}} = cir.abs {{%.*}} : !cir.vector<!s32i x 4> | ||
// LLVM: {{%.*}} = call <4 x i32> @llvm.abs.v4i32(<4 x i32> {{%.*}}, i1 false) | ||
vi4 = __builtin_elementwise_abs(vi4); | ||
|
||
// CIR: {{%.*}} = cir.abs {{%.*}} : !s32 | ||
// LLVM: {{%.*}} = call i32 @llvm.abs.i32(i32 {{%.*}}, i1 false) | ||
i = __builtin_elementwise_abs(i); | ||
} |