-
Notifications
You must be signed in to change notification settings - Fork 15k
RISCV: the builtins support for MIPS RV64 P8700 execution control . #159246
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
RISCV: the builtins support for MIPS RV64 P8700 execution control . #159246
Conversation
|
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-clang Author: UmeshKalappa (ukalappa-mips) Changeswith this PR ,the following changes are made a)Typo Fix (with previous PR #155747) Full diff: https://github.com/llvm/llvm-project/pull/159246.diff 8 Files Affected:
diff --git a/clang/include/clang/Basic/BuiltinsRISCV.td b/clang/include/clang/Basic/BuiltinsRISCV.td
index 5927eaf80d57a..2dad5ede2d64b 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.td
+++ b/clang/include/clang/Basic/BuiltinsRISCV.td
@@ -162,3 +162,8 @@ include "clang/Basic/BuiltinsRISCVXCV.td"
// XAndes extensions.
//===----------------------------------------------------------------------===//
include "clang/Basic/BuiltinsRISCVXAndes.td"
+
+//===----------------------------------------------------------------------===//
+// MIPS extensions.
+//===----------------------------------------------------------------------===//
+include "clang/Basic/BuiltinsRISCVXMIPS.td"
diff --git a/clang/include/clang/Basic/BuiltinsRISCVXMIPS.td b/clang/include/clang/Basic/BuiltinsRISCVXMIPS.td
new file mode 100644
index 0000000000000..28cf6c9bb1707
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsRISCVXMIPS.td
@@ -0,0 +1,27 @@
+//==- BuiltinsRISCVXMIPS.td - RISC-V MIPS Builtin database ----*- C++ -*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the MIPS-specific builtin function database. Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+class RISCVXMIPSBuiltin<string prototype, string features = ""> : TargetBuiltin {
+ let Spellings = ["__builtin_riscv_" # NAME];
+ let Prototype = prototype;
+ let Features = features;
+}
+
+//===----------------------------------------------------------------------===//
+// MIPS execution control extensions .
+//===----------------------------------------------------------------------===//
+let Attributes = [NoThrow, Const] in {
+def mips_pause : RISCVXMIPSBuiltin<"void()", "xmipsexectl">;
+def mips_ehb : RISCVXMIPSBuiltin<"void()", "xmipsexectl">;
+def mips_ihb : RISCVXMIPSBuiltin<"void()", "xmipsexectl">;
+}
\ No newline at end of file
diff --git a/clang/test/CodeGen/builtins-riscv-mips.c b/clang/test/CodeGen/builtins-riscv-mips.c
new file mode 100644
index 0000000000000..3c6c9b994f5d2
--- /dev/null
+++ b/clang/test/CodeGen/builtins-riscv-mips.c
@@ -0,0 +1,35 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
+// RUN: %clang_cc1 -triple riscv32-linux-elf -O3 -target-feature +xmipsexectl -emit-llvm -o - %s | FileCheck %s RISCV32
+
+// CHECK-LABEL: define dso_local void @test_mips_pause(
+// CHECK-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT: tail call void @llvm.riscv.mips.pause()
+// CHECK-NEXT: ret void
+//
+void test_mips_pause()
+{
+ __builtin_riscv_mips_pause();
+}
+
+// CHECK-LABEL: define dso_local void @test_mips_ehb(
+// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT: tail call void @llvm.riscv.mips.ehb()
+// CHECK-NEXT: ret void
+//
+void test_mips_ehb()
+{
+ __builtin_riscv_mips_ehb();
+}
+
+// CHECK-LABEL: define dso_local void @test_mips_ihb(
+// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT: tail call void @llvm.riscv.mips.ihb()
+// CHECK-NEXT: ret void
+//
+void test_mips_ihb()
+{
+ __builtin_riscv_mips_ihb();
+}
diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index 878f7b3194830..bd2c95c5af587 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -1949,3 +1949,4 @@ include "llvm/IR/IntrinsicsRISCVXTHead.td"
include "llvm/IR/IntrinsicsRISCVXsf.td"
include "llvm/IR/IntrinsicsRISCVXCV.td"
include "llvm/IR/IntrinsicsRISCVXAndes.td"
+include "llvm/IR/IntrinsicsRISCVXMIPS.td"
diff --git a/llvm/include/llvm/IR/IntrinsicsRISCVXMIPS.td b/llvm/include/llvm/IR/IntrinsicsRISCVXMIPS.td
new file mode 100644
index 0000000000000..ced96ac2e10a7
--- /dev/null
+++ b/llvm/include/llvm/IR/IntrinsicsRISCVXMIPS.td
@@ -0,0 +1,20 @@
+//===- IntrinsicsRISCVXMIPS.td - Defines MIPS intrinsics -------*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines all of the MIPS specific intrinsics for RISCV.
+//
+//===----------------------------------------------------------------------===//
+
+let TargetPrefix = "riscv" in {
+ def int_riscv_mips_pause : ClangBuiltin<"__builtin_riscv_mips_pause">,
+ Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>;
+ def int_riscv_mips_ehb : ClangBuiltin<"__builtin_riscv_mips_ehb">,
+ Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>;
+ def int_riscv_mips_ihb : ClangBuiltin<"__builtin_riscv_mips_ihb">,
+ Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>;
+}
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 95703e33926c5..6433fe888b894 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1426,7 +1426,7 @@ def NoVendorXMIPSCBOP : Predicate<"!Subtarget->hasVendorXMIPSCBOP()">;
def FeatureVendorXMIPSEXECTL : RISCVExtension<1, 0, "MIPS execution control">;
def HasVendorXMIPSEXECTL
- : Predicate<"Subtarget->hasVendorXMIPSEXT()">,
+ : Predicate<"Subtarget->hasVendorXMIPSEXECTL()">,
AssemblerPredicate<(all_of FeatureVendorXMIPSEXECTL),
"'Xmipsexectl' (MIPS execution control)">;
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
index d615094329b28..115ab38e5d4c1 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
@@ -143,6 +143,13 @@ let Predicates = [HasVendorXMIPSEXECTL], DecoderNamespace = "XMIPS" in {
def MIPS_PAUSE : MIPSExtInst_ri<0b000101, "mips.pause">;
}
+let Predicates = [HasVendorXMIPSEXECTL] in {
+ // Intrinsics
+ def : Pat<(int_riscv_mips_pause), (MIPS_PAUSE)>;
+ def : Pat<(int_riscv_mips_ihb), (MIPS_IHB)>;
+ def : Pat<(int_riscv_mips_ehb), (MIPS_EHB)>;
+}
+
let Predicates = [HasVendorXMIPSCBOP], DecoderNamespace = "XMIPS" in {
def MIPS_PREF : Mips_prefetch_ri<(outs), (ins GPR:$rs1, uimm9:$imm9, uimm5:$hint),
"mips.pref", "$hint, ${imm9}(${rs1})">,
diff --git a/llvm/test/CodeGen/RISCV/xmips-exectl.ll b/llvm/test/CodeGen/RISCV/xmips-exectl.ll
new file mode 100644
index 0000000000000..bc0c96e7301b2
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/xmips-exectl.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --tool /home/ukalappa/llvm/github/build/bin/llc --version 6
+; RUN: llc -mtriple=riscv64 -mcpu=mips-p8700 -O3 -verify-machineinstrs < %s \
+; RUN: | FileCheck -check-prefix=MIPS %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
+
+define dso_local void @test_mips_pause() local_unnamed_addr {
+; MIPS-LABEL: test_mips_pause:
+; MIPS: # %bb.0: # %entry
+; MIPS-NEXT: mips.pause
+; MIPS-NEXT: ret
+entry:
+ tail call void @llvm.riscv.mips.pause()
+ ret void
+}
+
+define dso_local void @test_mips_ehb() local_unnamed_addr {
+; MIPS-LABEL: test_mips_ehb:
+; MIPS: # %bb.0: # %entry
+; MIPS-NEXT: mips.ehb
+; MIPS-NEXT: ret
+entry:
+ tail call void @llvm.riscv.mips.ehb()
+ ret void
+}
+
+define dso_local void @test_mips_ihb() local_unnamed_addr {
+; MIPS-LABEL: test_mips_ihb:
+; MIPS: # %bb.0: # %entry
+; MIPS-NEXT: mips.ihb
+; MIPS-NEXT: ret
+entry:
+ tail call void @llvm.riscv.mips.ihb()
+ ret void
+}
|
|
@llvm/pr-subscribers-backend-risc-v Author: UmeshKalappa (ukalappa-mips) Changeswith this PR ,the following changes are made a)Typo Fix (with previous PR #155747) Full diff: https://github.com/llvm/llvm-project/pull/159246.diff 8 Files Affected:
diff --git a/clang/include/clang/Basic/BuiltinsRISCV.td b/clang/include/clang/Basic/BuiltinsRISCV.td
index 5927eaf80d57a..2dad5ede2d64b 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.td
+++ b/clang/include/clang/Basic/BuiltinsRISCV.td
@@ -162,3 +162,8 @@ include "clang/Basic/BuiltinsRISCVXCV.td"
// XAndes extensions.
//===----------------------------------------------------------------------===//
include "clang/Basic/BuiltinsRISCVXAndes.td"
+
+//===----------------------------------------------------------------------===//
+// MIPS extensions.
+//===----------------------------------------------------------------------===//
+include "clang/Basic/BuiltinsRISCVXMIPS.td"
diff --git a/clang/include/clang/Basic/BuiltinsRISCVXMIPS.td b/clang/include/clang/Basic/BuiltinsRISCVXMIPS.td
new file mode 100644
index 0000000000000..28cf6c9bb1707
--- /dev/null
+++ b/clang/include/clang/Basic/BuiltinsRISCVXMIPS.td
@@ -0,0 +1,27 @@
+//==- BuiltinsRISCVXMIPS.td - RISC-V MIPS Builtin database ----*- C++ -*-==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the MIPS-specific builtin function database. Users of
+// this file must define the BUILTIN macro to make use of this information.
+//
+//===----------------------------------------------------------------------===//
+
+class RISCVXMIPSBuiltin<string prototype, string features = ""> : TargetBuiltin {
+ let Spellings = ["__builtin_riscv_" # NAME];
+ let Prototype = prototype;
+ let Features = features;
+}
+
+//===----------------------------------------------------------------------===//
+// MIPS execution control extensions .
+//===----------------------------------------------------------------------===//
+let Attributes = [NoThrow, Const] in {
+def mips_pause : RISCVXMIPSBuiltin<"void()", "xmipsexectl">;
+def mips_ehb : RISCVXMIPSBuiltin<"void()", "xmipsexectl">;
+def mips_ihb : RISCVXMIPSBuiltin<"void()", "xmipsexectl">;
+}
\ No newline at end of file
diff --git a/clang/test/CodeGen/builtins-riscv-mips.c b/clang/test/CodeGen/builtins-riscv-mips.c
new file mode 100644
index 0000000000000..3c6c9b994f5d2
--- /dev/null
+++ b/clang/test/CodeGen/builtins-riscv-mips.c
@@ -0,0 +1,35 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
+// RUN: %clang_cc1 -triple riscv32-linux-elf -O3 -target-feature +xmipsexectl -emit-llvm -o - %s | FileCheck %s RISCV32
+
+// CHECK-LABEL: define dso_local void @test_mips_pause(
+// CHECK-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT: tail call void @llvm.riscv.mips.pause()
+// CHECK-NEXT: ret void
+//
+void test_mips_pause()
+{
+ __builtin_riscv_mips_pause();
+}
+
+// CHECK-LABEL: define dso_local void @test_mips_ehb(
+// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT: tail call void @llvm.riscv.mips.ehb()
+// CHECK-NEXT: ret void
+//
+void test_mips_ehb()
+{
+ __builtin_riscv_mips_ehb();
+}
+
+// CHECK-LABEL: define dso_local void @test_mips_ihb(
+// CHECK-SAME: ) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT: tail call void @llvm.riscv.mips.ihb()
+// CHECK-NEXT: ret void
+//
+void test_mips_ihb()
+{
+ __builtin_riscv_mips_ihb();
+}
diff --git a/llvm/include/llvm/IR/IntrinsicsRISCV.td b/llvm/include/llvm/IR/IntrinsicsRISCV.td
index 878f7b3194830..bd2c95c5af587 100644
--- a/llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ b/llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ -1949,3 +1949,4 @@ include "llvm/IR/IntrinsicsRISCVXTHead.td"
include "llvm/IR/IntrinsicsRISCVXsf.td"
include "llvm/IR/IntrinsicsRISCVXCV.td"
include "llvm/IR/IntrinsicsRISCVXAndes.td"
+include "llvm/IR/IntrinsicsRISCVXMIPS.td"
diff --git a/llvm/include/llvm/IR/IntrinsicsRISCVXMIPS.td b/llvm/include/llvm/IR/IntrinsicsRISCVXMIPS.td
new file mode 100644
index 0000000000000..ced96ac2e10a7
--- /dev/null
+++ b/llvm/include/llvm/IR/IntrinsicsRISCVXMIPS.td
@@ -0,0 +1,20 @@
+//===- IntrinsicsRISCVXMIPS.td - Defines MIPS intrinsics -------*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines all of the MIPS specific intrinsics for RISCV.
+//
+//===----------------------------------------------------------------------===//
+
+let TargetPrefix = "riscv" in {
+ def int_riscv_mips_pause : ClangBuiltin<"__builtin_riscv_mips_pause">,
+ Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>;
+ def int_riscv_mips_ehb : ClangBuiltin<"__builtin_riscv_mips_ehb">,
+ Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>;
+ def int_riscv_mips_ihb : ClangBuiltin<"__builtin_riscv_mips_ihb">,
+ Intrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>;
+}
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 95703e33926c5..6433fe888b894 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1426,7 +1426,7 @@ def NoVendorXMIPSCBOP : Predicate<"!Subtarget->hasVendorXMIPSCBOP()">;
def FeatureVendorXMIPSEXECTL : RISCVExtension<1, 0, "MIPS execution control">;
def HasVendorXMIPSEXECTL
- : Predicate<"Subtarget->hasVendorXMIPSEXT()">,
+ : Predicate<"Subtarget->hasVendorXMIPSEXECTL()">,
AssemblerPredicate<(all_of FeatureVendorXMIPSEXECTL),
"'Xmipsexectl' (MIPS execution control)">;
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
index d615094329b28..115ab38e5d4c1 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXMips.td
@@ -143,6 +143,13 @@ let Predicates = [HasVendorXMIPSEXECTL], DecoderNamespace = "XMIPS" in {
def MIPS_PAUSE : MIPSExtInst_ri<0b000101, "mips.pause">;
}
+let Predicates = [HasVendorXMIPSEXECTL] in {
+ // Intrinsics
+ def : Pat<(int_riscv_mips_pause), (MIPS_PAUSE)>;
+ def : Pat<(int_riscv_mips_ihb), (MIPS_IHB)>;
+ def : Pat<(int_riscv_mips_ehb), (MIPS_EHB)>;
+}
+
let Predicates = [HasVendorXMIPSCBOP], DecoderNamespace = "XMIPS" in {
def MIPS_PREF : Mips_prefetch_ri<(outs), (ins GPR:$rs1, uimm9:$imm9, uimm5:$hint),
"mips.pref", "$hint, ${imm9}(${rs1})">,
diff --git a/llvm/test/CodeGen/RISCV/xmips-exectl.ll b/llvm/test/CodeGen/RISCV/xmips-exectl.ll
new file mode 100644
index 0000000000000..bc0c96e7301b2
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/xmips-exectl.ll
@@ -0,0 +1,35 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --tool /home/ukalappa/llvm/github/build/bin/llc --version 6
+; RUN: llc -mtriple=riscv64 -mcpu=mips-p8700 -O3 -verify-machineinstrs < %s \
+; RUN: | FileCheck -check-prefix=MIPS %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
+
+define dso_local void @test_mips_pause() local_unnamed_addr {
+; MIPS-LABEL: test_mips_pause:
+; MIPS: # %bb.0: # %entry
+; MIPS-NEXT: mips.pause
+; MIPS-NEXT: ret
+entry:
+ tail call void @llvm.riscv.mips.pause()
+ ret void
+}
+
+define dso_local void @test_mips_ehb() local_unnamed_addr {
+; MIPS-LABEL: test_mips_ehb:
+; MIPS: # %bb.0: # %entry
+; MIPS-NEXT: mips.ehb
+; MIPS-NEXT: ret
+entry:
+ tail call void @llvm.riscv.mips.ehb()
+ ret void
+}
+
+define dso_local void @test_mips_ihb() local_unnamed_addr {
+; MIPS-LABEL: test_mips_ihb:
+; MIPS: # %bb.0: # %entry
+; MIPS-NEXT: mips.ihb
+; MIPS-NEXT: ret
+entry:
+ tail call void @llvm.riscv.mips.ihb()
+ ret void
+}
|
3ad2287 to
5525ab5
Compare
|
@topperc , @wangpc-pp and @mshockwave ,any further comment's ? |
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.
LGTM.
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.
LGTM
458e3d4 to
5525ab5
Compare
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
a68146f to
5525ab5
Compare
3cd6f9b to
9aa3bd3
Compare
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.
LGTM.
with this PR ,the following changes are made
a)Typo Fix (with previous PR #155747)
b)builtins support for MIPS P8700 execution control instructions .
c)Testcase