-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AArch64] Implement GCS ACLE intrinsics #96903
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we ever expect these builtins to be called separately? If not, what's the rationale for having two of them, rather than one that does both operations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having builtins that directly match the instructions is more convenient in terms of implementation. Tablegen gives the error "Cannot handle instructions producing instructions with temporaries yet!" if you try to have a pattern with two output instructions when the output of one isn't the input of another, so this would require custom lowering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concerns are:
sideEffects = 1
on the instructions should prevent a lot of these, but I'm not clear on things that should be side-effect safe but might interact with GCS such as Machine Outliner.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out to be not that difficult to have a single builtin, so I've done that.