Skip to content

Commit 9aa3bd3

Browse files
committed
Added Headers to wrapped around the mips builtins.
1 parent 5525ab5 commit 9aa3bd3

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

clang/lib/Headers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ set(riscv_files
131131
riscv_ntlh.h
132132
sifive_vector.h
133133
andes_vector.h
134+
riscv_mips.h
134135
)
135136

136137
set(spirv_files

clang/lib/Headers/riscv_mips.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//===----- riscv_mips.h - RISC-V MIPS Intrinsic definitions
2+
//----------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef __RISCV_MIPS_H
11+
#define __RISCV_MIPS_H
12+
13+
#if !defined(__riscv)
14+
#error "This header is only meant to be used on riscv architecture"
15+
#endif
16+
17+
#define __DEFAULT_FN_ATTRS \
18+
__attribute__((__always_inline__, __nodebug__, __target__("xmipsexectl")))
19+
20+
static __inline__ void __DEFAULT_FN_ATTRS __mips_pause() {
21+
__builtin_riscv_mips_pause();
22+
}
23+
24+
static __inline__ void __DEFAULT_FN_ATTRS __mips_ehb() {
25+
__builtin_riscv_mips_ehb();
26+
}
27+
28+
static __inline__ void __DEFAULT_FN_ATTRS __mips_ihb() {
29+
__builtin_riscv_mips_ihb();
30+
}
31+
32+
#undef __DEFAULT_FN_ATTRS
33+
34+
#endif

clang/test/CodeGen/builtins-riscv-mips.c renamed to clang/test/CodeGen/RISCV/builtins-riscv-mips.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
22
// RUN: %clang_cc1 -triple riscv32-linux-elf -O3 -target-feature +xmipsexectl -emit-llvm -o - %s | FileCheck %s
33

4+
#include<riscv_mips.h>
5+
46
// CHECK-LABEL: define dso_local void @test_mips_pause(
57
// CHECK-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] {
68
// CHECK-NEXT: [[ENTRY:.*:]]
@@ -9,7 +11,7 @@
911
//
1012
void test_mips_pause()
1113
{
12-
__builtin_riscv_mips_pause();
14+
__mips_pause();
1315
}
1416

1517
// CHECK-LABEL: define dso_local void @test_mips_ehb(
@@ -20,7 +22,7 @@ void test_mips_pause()
2022
//
2123
void test_mips_ehb()
2224
{
23-
__builtin_riscv_mips_ehb();
25+
__mips_ehb();
2426
}
2527

2628
// CHECK-LABEL: define dso_local void @test_mips_ihb(
@@ -31,5 +33,5 @@ void test_mips_ehb()
3133
//
3234
void test_mips_ihb()
3335
{
34-
__builtin_riscv_mips_ihb();
36+
__mips_ihb();
3537
}

0 commit comments

Comments
 (0)