Page MenuHomePhabricator

[RISCV] [2/2] Add intrinsic for Zbr extension
Needs ReviewPublic

Authored by LevyHsu on Mar 19 2021, 9:57 PM.

Details

Summary

Implementation for RISC-V Zbr extension intrinsics.

Head files are included in the second patch in case the name needs to be changed

RV32 / 64:

crc32b
crc32h
crc32w
crc32cb
crc32ch
crc32cw

RV64 Only:

crc32d
crc32cd

Diff Detail

Unit TestsFailed

TimeTest
70 msx64 debian > Clang.CodeGen/RISCV/rvb-intrinsics::riscv32-zbr.c
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/clang -cc1 -internal-isystem /mnt/disks/ssd0/agent/llvm-project/build/lib/clang/13.0.0/include -nostdsysteminc -triple riscv32 -target-feature +experimental-zbr -emit-llvm /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c -o - | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c -check-prefix=RV32ZBR
80 msx64 debian > Clang.CodeGen/RISCV/rvb-intrinsics::riscv64-zbr.c
Script: -- : 'RUN: at line 2'; /mnt/disks/ssd0/agent/llvm-project/build/bin/clang -cc1 -internal-isystem /mnt/disks/ssd0/agent/llvm-project/build/lib/clang/13.0.0/include -nostdsysteminc -triple riscv64 -target-feature +experimental-zbr -emit-llvm /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c -o - | /mnt/disks/ssd0/agent/llvm-project/build/bin/FileCheck /mnt/disks/ssd0/agent/llvm-project/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c -check-prefix=RV64ZBR
90 msx64 windows > Clang.CodeGen/RISCV/rvb-intrinsics::riscv32-zbr.c
Script: -- : 'RUN: at line 2'; c:\ws\w16e2-1\llvm-project\premerge-checks\build\bin\clang.exe -cc1 -internal-isystem c:\ws\w16e2-1\llvm-project\premerge-checks\build\lib\clang\13.0.0\include -nostdsysteminc -triple riscv32 -target-feature +experimental-zbr -emit-llvm C:\ws\w16e2-1\llvm-project\premerge-checks\clang\test\CodeGen\RISCV\rvb-intrinsics\riscv32-zbr.c -o - | c:\ws\w16e2-1\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w16e2-1\llvm-project\premerge-checks\clang\test\CodeGen\RISCV\rvb-intrinsics\riscv32-zbr.c -check-prefix=RV32ZBR
140 msx64 windows > Clang.CodeGen/RISCV/rvb-intrinsics::riscv64-zbr.c
Script: -- : 'RUN: at line 2'; c:\ws\w16e2-1\llvm-project\premerge-checks\build\bin\clang.exe -cc1 -internal-isystem c:\ws\w16e2-1\llvm-project\premerge-checks\build\lib\clang\13.0.0\include -nostdsysteminc -triple riscv64 -target-feature +experimental-zbr -emit-llvm C:\ws\w16e2-1\llvm-project\premerge-checks\clang\test\CodeGen\RISCV\rvb-intrinsics\riscv64-zbr.c -o - | c:\ws\w16e2-1\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w16e2-1\llvm-project\premerge-checks\clang\test\CodeGen\RISCV\rvb-intrinsics\riscv64-zbr.c -check-prefix=RV64ZBR

Event Timeline

LevyHsu created this revision.Mar 19 2021, 9:57 PM
LevyHsu requested review of this revision.Mar 19 2021, 9:57 PM
LevyHsu updated this revision to Diff 332076.Mar 19 2021, 9:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 19 2021, 9:58 PM
LevyHsu retitled this revision from [RISCV] Add intrinsic for Zbr extension to [RISCV] Add intrinsic for Zbr extension (2/2).Mar 19 2021, 10:20 PM
LevyHsu edited the summary of this revision. (Show Details)
LevyHsu retitled this revision from [RISCV] Add intrinsic for Zbr extension (2/2) to [RISCV] [2/2] Add intrinsic for Zbr extension.

Please note I asked that this patch be separate from D99009 because the rvintrin.h file name may not be the final filename we want to use. This https://github.com/riscv/riscv-c-api-doc/pull/14 suggests it should be riscv_intrinsic.h. So I wanted to separate any discussion about how it should be exposed to the user from the implementation of the IR intrinsics and clang builtins.

LevyHsu updated this revision to Diff 332565.Mar 23 2021, 1:54 AM
LevyHsu edited the summary of this revision. (Show Details)
  1. Format fix
  2. rvintrin.c is moved to the second part of the pach
LevyHsu updated this revision to Diff 333219.Mar 24 2021, 11:58 PM

in clang/test/Headers/rvintrin.c
RUN: -target-feature +experimental-zbr %s

LevyHsu edited the summary of this revision. (Show Details)Mar 25 2021, 12:17 AM
craig.topper added inline comments.Mar 25 2021, 4:44 PM
clang/lib/Headers/riscv_zbr_intrin.h
10

Please add

#ifndef __RVINTRIN_H                                                                                                                                                                                                                                                              
#error "Never use <riscv_zbr_intrin.h> directly; include <rvintrin.h> instead."
#endif

This file doesn't work if you include it by itself because it references int_xlen_t and __DEFAULT_FN_ATTRS which aren't defined in this file.

LevyHsu updated this revision to Diff 334332.Mar 30 2021, 8:15 PM
  1. clang/lib/Headers/riscv_zbr_intrin.h
    • Fix coding style issues
    • Added error messages to alert user not include this headfile directly.
  2. clang/lib/Headers/rvintrin.h
    • Fix coding style issues.