forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AArch64] Implement GCS ACLE intrinsics
This adds intrinsics defined in ARM-software/acle#260 Doing this requires some changes to the GCS instruction definitions, as these intrinsics make use of how some instructions don't modify the input register when GCS is disabled, and they need to be correctly marked with mayLoad/mayStore/hasSideEffects for instruction selection to work.
- Loading branch information
1 parent
dfd2711
commit 123ebe1
Showing
6 changed files
with
173 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 | ||
// RUN: %clang_cc1 -triple aarch64-eabi -target-feature +gcs -emit-llvm %s -o - | FileCheck %s | ||
|
||
#include <arm_acle.h> | ||
|
||
// CHECK-LABEL: define dso_local i64 @test_chkfeat | ||
// CHECK-SAME: () #[[ATTR0:[0-9]+]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[__FEATURES_ADDR_I:%.*]] = alloca i64, align 8 | ||
// CHECK-NEXT: store i64 1, ptr [[__FEATURES_ADDR_I]], align 8 | ||
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr [[__FEATURES_ADDR_I]], align 8 | ||
// CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.aarch64.chkfeat(i64 [[TMP0]]) | ||
// CHECK-NEXT: [[TMP2:%.*]] = load i64, ptr [[__FEATURES_ADDR_I]], align 8 | ||
// CHECK-NEXT: [[XOR_I:%.*]] = xor i64 [[TMP1]], [[TMP2]] | ||
// CHECK-NEXT: ret i64 [[XOR_I]] | ||
// | ||
uint64_t test_chkfeat() { | ||
return __chkfeat(_CHKFEAT_GCS); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local ptr @test_gcspr | ||
// CHECK-SAME: () #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.read_volatile_register.i64(metadata [[META2:![0-9]+]]) | ||
// CHECK-NEXT: [[TMP1:%.*]] = inttoptr i64 [[TMP0]] to ptr | ||
// CHECK-NEXT: ret ptr [[TMP1]] | ||
// | ||
void *test_gcspr() { | ||
return __gcspr(); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local i64 @test_gcspopm | ||
// CHECK-SAME: () #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.aarch64.gcspopm(i64 0) | ||
// CHECK-NEXT: ret i64 [[TMP0]] | ||
// | ||
uint64_t test_gcspopm() { | ||
return __gcspopm(); | ||
} | ||
|
||
// CHECK-LABEL: define dso_local ptr @test_gcsss | ||
// CHECK-SAME: (ptr noundef [[P:%.*]]) #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: [[__STACK_ADDR_I:%.*]] = alloca ptr, align 8 | ||
// CHECK-NEXT: [[P_ADDR:%.*]] = alloca ptr, align 8 | ||
// CHECK-NEXT: store ptr [[P]], ptr [[P_ADDR]], align 8 | ||
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P_ADDR]], align 8 | ||
// CHECK-NEXT: store ptr [[TMP0]], ptr [[__STACK_ADDR_I]], align 8 | ||
// CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[__STACK_ADDR_I]], align 8 | ||
// CHECK-NEXT: call void @llvm.aarch64.gcsss1(ptr [[TMP1]]) | ||
// CHECK-NEXT: [[TMP2:%.*]] = call ptr @llvm.aarch64.gcsss2(ptr null) | ||
// CHECK-NEXT: ret ptr [[TMP2]] | ||
// | ||
const void *test_gcsss(const void *p) { | ||
return __gcsss(p); | ||
} |
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,49 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=aarch64 -mattr=+gcs -verify-machineinstrs -o - %s | FileCheck %s | ||
|
||
define i64 @test_chkfeat(i64 %arg) { | ||
; CHECK-LABEL: test_chkfeat: | ||
; CHECK: // %bb.0: // %entry | ||
; CHECK-NEXT: mov x16, x0 | ||
; CHECK-NEXT: chkfeat x16 | ||
; CHECK-NEXT: mov x0, x16 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%0 = call i64 @llvm.aarch64.chkfeat(i64 %arg) | ||
ret i64 %0 | ||
} | ||
|
||
define i64 @test_gcspopm(i64 %arg) { | ||
; CHECK-LABEL: test_gcspopm: | ||
; CHECK: // %bb.0: // %entry | ||
; CHECK-NEXT: gcspopm x0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%0 = call i64 @llvm.aarch64.gcspopm(i64 %arg) | ||
ret i64 %0 | ||
} | ||
|
||
define void @test_gcsss1(ptr %p) { | ||
; CHECK-LABEL: test_gcsss1: | ||
; CHECK: // %bb.0: // %entry | ||
; CHECK-NEXT: gcsss1 x0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
call void @llvm.aarch64.gcsss1(ptr %p) | ||
ret void | ||
} | ||
|
||
define ptr @test_gcsss2(ptr %p) { | ||
; CHECK-LABEL: test_gcsss2: | ||
; CHECK: // %bb.0: // %entry | ||
; CHECK-NEXT: gcsss2 x0 | ||
; CHECK-NEXT: ret | ||
entry: | ||
%0 = call ptr @llvm.aarch64.gcsss2(ptr %p) | ||
ret ptr %0 | ||
} | ||
|
||
declare i64 @llvm.aarch64.chkfeat(i64) | ||
declare i64 @llvm.aarch64.gcspopm(i64) | ||
declare void @llvm.aarch64.gcsss1(ptr) | ||
declare ptr @llvm.aarch64.gcsss2(ptr) |