-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][RISCV] Refactor builtins to TableGen
This mechanism is introduced by #68324. This refactor makes the prototype and attributes clear. Reviewers: asb, kito-cheng, philnik777, topperc, preames Reviewed By: topperc Pull Request: #80280
- Loading branch information
Showing
6 changed files
with
154 additions
and
96 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,148 @@ | ||
//==- BuiltinsRISCV.td - RISC-V Builtin function database ---*- 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 the RISC-V-specific builtin function database. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
include "clang/Basic/BuiltinsBase.td" | ||
|
||
class RISCVBuiltin<string prototype, string features = ""> : TargetBuiltin { | ||
let Spellings = ["__builtin_riscv_" # NAME]; | ||
let Prototype = prototype; | ||
let Features = features; | ||
} | ||
|
||
let Attributes = [NoThrow, Const] in { | ||
//===----------------------------------------------------------------------===// | ||
// Zbb extension. | ||
//===----------------------------------------------------------------------===// | ||
def orc_b_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbb">; | ||
def orc_b_64 : RISCVBuiltin<"uint64_t(uint64_t)", "zbb,64bit">; | ||
def clz_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbb|xtheadbb">; | ||
def clz_64 : RISCVBuiltin<"unsigned int(uint64_t)", "zbb|xtheadbb,64bit">; | ||
def ctz_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbb">; | ||
def ctz_64 : RISCVBuiltin<"unsigned int(uint64_t)", "zbb,64bit">; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zbc or Zbkc extension. | ||
//===----------------------------------------------------------------------===// | ||
def clmul_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)", "zbc|zbkc">; | ||
def clmul_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)", "zbc|zbkc,64bit">; | ||
def clmulh_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)", "zbc|zbkc,32bit">; | ||
def clmulh_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)", "zbc|zbkc,64bit">; | ||
def clmulr_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)", "zbc,32bit">; | ||
def clmulr_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)", "zbc,64bit">; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zbkx extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zbkx,32bit" in { | ||
def xperm4_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
def xperm8_32 : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
} // Features = "zbkx,32bit" | ||
|
||
let Features = "zbkx,64bit" in { | ||
def xperm4_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">; | ||
def xperm8_64 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">; | ||
} // Features = "zbkx,64bit" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zbkb extension. | ||
//===----------------------------------------------------------------------===// | ||
def brev8_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbkb">; | ||
def brev8_64 : RISCVBuiltin<"uint64_t(uint64_t)", "zbkb,64bit">; | ||
def zip_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbkb,32bit">; | ||
def unzip_32 : RISCVBuiltin<"unsigned int(unsigned int)", "zbkb,32bit">; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zknd extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zknd,32bit" in { | ||
def aes32dsi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">; | ||
def aes32dsmi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">; | ||
} // Features = "zknd,32bit" | ||
|
||
let Features = "zknd,64bit" in { | ||
def aes64ds : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">; | ||
def aes64dsm : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">; | ||
def aes64im : RISCVBuiltin<"uint64_t(uint64_t)">; | ||
} // Features = "zknd,64bit" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zknd & Zkne extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zknd|zkne,64bit" in { | ||
def aes64ks1i : RISCVBuiltin<"uint64_t(uint64_t, _Constant unsigned int)">; | ||
def aes64ks2 : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">; | ||
} // Features = "zknd|zkne,64bit" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zkne extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zkne,32bit" in { | ||
def aes32esi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">; | ||
def aes32esmi : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">; | ||
} // Features = "zkne,32bit" | ||
|
||
let Features = "zkne,64bit" in { | ||
def aes64es : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">; | ||
def aes64esm : RISCVBuiltin<"uint64_t(uint64_t, uint64_t)">; | ||
} // Features = "zkne,64bit" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zknh extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zknh" in { | ||
def sha256sig0 : RISCVBuiltin<"unsigned int(unsigned int)">; | ||
def sha256sig1 : RISCVBuiltin<"unsigned int(unsigned int)">; | ||
def sha256sum0 : RISCVBuiltin<"unsigned int(unsigned int)">; | ||
def sha256sum1 : RISCVBuiltin<"unsigned int(unsigned int)">; | ||
} // Features = "zknh" | ||
|
||
let Features = "zknh,32bit" in { | ||
def sha512sig0h : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
def sha512sig0l : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
def sha512sig1h : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
def sha512sig1l : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
def sha512sum0r : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
def sha512sum1r : RISCVBuiltin<"unsigned int(unsigned int, unsigned int)">; | ||
} // Features = "zknh,32bit" | ||
|
||
let Features = "zknh,64bit" in { | ||
def sha512sig0 : RISCVBuiltin<"uint64_t(uint64_t)">; | ||
def sha512sig1 : RISCVBuiltin<"uint64_t(uint64_t)">; | ||
def sha512sum0 : RISCVBuiltin<"uint64_t(uint64_t)">; | ||
def sha512sum1 : RISCVBuiltin<"uint64_t(uint64_t)">; | ||
} // Features = "zknh,64bit" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zksed extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zksed" in { | ||
def sm4ed : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int )">; | ||
def sm4ks : RISCVBuiltin<"unsigned int(unsigned int, unsigned int, _Constant unsigned int)">; | ||
} // Features = "zksed" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zksh extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zksh" in { | ||
def sm3p0 : RISCVBuiltin<"unsigned int(unsigned int)">; | ||
def sm3p1 : RISCVBuiltin<"unsigned int(unsigned int)">; | ||
} // Features = "zksh" | ||
|
||
} // Attributes = [Const, NoThrow] | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Zihintntl extension. | ||
//===----------------------------------------------------------------------===// | ||
let Features = "zihintntl", Attributes = [CustomTypeChecking] in { | ||
def ntl_load : RISCVBuiltin<"void(...)">; | ||
def ntl_store : RISCVBuiltin<"void(...)">; | ||
} // Features = "zihintntl", Attributes = [CustomTypeChecking] |
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