[Clang][VE] Add vector load intrinsics

Add vector load intrinsic instructions for VE.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D121049
This commit is contained in:
Kazushi (Jam) Marukawa 2022-03-06 01:17:04 +09:00
parent 229d576b31
commit b1b4b6f366
10 changed files with 369 additions and 2 deletions

View File

@ -0,0 +1,17 @@
//===--- BuiltinsVE.def - VE Builtin function 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 VE-specific builtin function database. Users of
// this file must define the BUILTIN macro to make use of this information.
//
//===----------------------------------------------------------------------===//
// Use generated BUILTIN definitions
#include "clang/Basic/BuiltinsVEVL.gen.def"
#undef BUILTIN

View File

@ -0,0 +1,32 @@
BUILTIN(__builtin_ve_vl_vld_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vld_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldnc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldnc_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldu_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldu_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldunc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldunc_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldlsx_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldlsx_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldlsxnc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldlsxnc_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldlzx_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldlzx_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldlzxnc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldlzxnc_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vld2d_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vld2d_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vld2dnc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vld2dnc_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldu2d_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldu2d_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldu2dnc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldu2dnc_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldl2dsx_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldl2dsx_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldl2dsxnc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldl2dsxnc_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldl2dzx_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldl2dzx_vssvl, "V256dLUivC*V256dUi", "n")
BUILTIN(__builtin_ve_vl_vldl2dzxnc_vssl, "V256dLUivC*Ui", "n")
BUILTIN(__builtin_ve_vl_vldl2dzxnc_vssvl, "V256dLUivC*V256dUi", "n")

View File

@ -121,7 +121,12 @@ namespace clang {
/// VE builtins
namespace VE {
enum { LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1, LastTSBuiltin };
enum {
LastTIBuiltin = clang::Builtin::FirstTSBuiltin - 1,
#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
#include "clang/Basic/BuiltinsVE.def"
LastTSBuiltin
};
}
namespace RISCVVector {

View File

@ -50,6 +50,7 @@ module Clang_Basic {
textual header "Basic/BuiltinsRISCVVector.def"
textual header "Basic/BuiltinsSVE.def"
textual header "Basic/BuiltinsSystemZ.def"
textual header "Basic/BuiltinsVE.def"
textual header "Basic/BuiltinsWebAssembly.def"
textual header "Basic/BuiltinsX86.def"
textual header "Basic/BuiltinsX86_64.def"

View File

@ -18,6 +18,12 @@
using namespace clang;
using namespace clang::targets;
const Builtin::Info VETargetInfo::BuiltinInfo[] = {
#define BUILTIN(ID, TYPE, ATTRS) \
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
#include "clang/Basic/BuiltinsVE.def"
};
void VETargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
Builder.defineMacro("_LP64", "1");
@ -35,5 +41,6 @@ void VETargetInfo::getTargetDefines(const LangOptions &Opts,
}
ArrayRef<Builtin::Info> VETargetInfo::getTargetBuiltins() const {
return ArrayRef<Builtin::Info>();
return llvm::makeArrayRef(BuiltinInfo,
clang::VE::LastTSBuiltin - Builtin::FirstTSBuiltin);
}

View File

@ -45,6 +45,7 @@
#include "llvm/IR/IntrinsicsR600.h"
#include "llvm/IR/IntrinsicsRISCV.h"
#include "llvm/IR/IntrinsicsS390.h"
#include "llvm/IR/IntrinsicsVE.h"
#include "llvm/IR/IntrinsicsWebAssembly.h"
#include "llvm/IR/IntrinsicsX86.h"
#include "llvm/IR/MDBuilder.h"

View File

@ -145,6 +145,8 @@ set(files
xsaveoptintrin.h
xsavesintrin.h
xtestintrin.h
velintrin.h
velintrin_gen.h
)
set(cuda_wrapper_files

View File

@ -0,0 +1,38 @@
/*===---- velintrin.h - VEL intrinsics for VE ------------------------------===
*
* 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
*
*===-----------------------------------------------------------------------===
*/
#ifndef __VEL_INTRIN_H__
#define __VEL_INTRIN_H__
// Vector registers
typedef double __vr __attribute__((__vector_size__(2048)));
// TODO: Vector mask registers
// Depend on https://reviews.llvm.org/D88905
#if 0
#if __STDC_VERSION__ >= 199901L
// For C99
typedef _Bool __vm __attribute__((ext_vector_type(256)));
typedef _Bool __vm256 __attribute__((ext_vector_type(256)));
typedef _Bool __vm512 __attribute__((ext_vector_type(512)));
#else
#ifdef __cplusplus
// For C++
typedef bool __vm __attribute__((ext_vector_type(256)));
typedef bool __vm256 __attribute__((ext_vector_type(256)));
typedef bool __vm512 __attribute__((ext_vector_type(512)));
#else
#error need C++ or C99 to use vector intrinsics for VE
#endif
#endif
#endif
// Use generated intrinsic name definitions
#include <velintrin_gen.h>
#endif

View File

@ -0,0 +1,32 @@
#define _vel_vld_vssl __builtin_ve_vl_vld_vssl
#define _vel_vld_vssvl __builtin_ve_vl_vld_vssvl
#define _vel_vldnc_vssl __builtin_ve_vl_vldnc_vssl
#define _vel_vldnc_vssvl __builtin_ve_vl_vldnc_vssvl
#define _vel_vldu_vssl __builtin_ve_vl_vldu_vssl
#define _vel_vldu_vssvl __builtin_ve_vl_vldu_vssvl
#define _vel_vldunc_vssl __builtin_ve_vl_vldunc_vssl
#define _vel_vldunc_vssvl __builtin_ve_vl_vldunc_vssvl
#define _vel_vldlsx_vssl __builtin_ve_vl_vldlsx_vssl
#define _vel_vldlsx_vssvl __builtin_ve_vl_vldlsx_vssvl
#define _vel_vldlsxnc_vssl __builtin_ve_vl_vldlsxnc_vssl
#define _vel_vldlsxnc_vssvl __builtin_ve_vl_vldlsxnc_vssvl
#define _vel_vldlzx_vssl __builtin_ve_vl_vldlzx_vssl
#define _vel_vldlzx_vssvl __builtin_ve_vl_vldlzx_vssvl
#define _vel_vldlzxnc_vssl __builtin_ve_vl_vldlzxnc_vssl
#define _vel_vldlzxnc_vssvl __builtin_ve_vl_vldlzxnc_vssvl
#define _vel_vld2d_vssl __builtin_ve_vl_vld2d_vssl
#define _vel_vld2d_vssvl __builtin_ve_vl_vld2d_vssvl
#define _vel_vld2dnc_vssl __builtin_ve_vl_vld2dnc_vssl
#define _vel_vld2dnc_vssvl __builtin_ve_vl_vld2dnc_vssvl
#define _vel_vldu2d_vssl __builtin_ve_vl_vldu2d_vssl
#define _vel_vldu2d_vssvl __builtin_ve_vl_vldu2d_vssvl
#define _vel_vldu2dnc_vssl __builtin_ve_vl_vldu2dnc_vssl
#define _vel_vldu2dnc_vssvl __builtin_ve_vl_vldu2dnc_vssvl
#define _vel_vldl2dsx_vssl __builtin_ve_vl_vldl2dsx_vssl
#define _vel_vldl2dsx_vssvl __builtin_ve_vl_vldl2dsx_vssvl
#define _vel_vldl2dsxnc_vssl __builtin_ve_vl_vldl2dsxnc_vssl
#define _vel_vldl2dsxnc_vssvl __builtin_ve_vl_vldl2dsxnc_vssvl
#define _vel_vldl2dzx_vssl __builtin_ve_vl_vldl2dzx_vssl
#define _vel_vldl2dzx_vssvl __builtin_ve_vl_vldl2dzx_vssvl
#define _vel_vldl2dzxnc_vssl __builtin_ve_vl_vldl2dzxnc_vssl
#define _vel_vldl2dzxnc_vssvl __builtin_ve_vl_vldl2dzxnc_vssvl

View File

@ -0,0 +1,232 @@
// REQUIRES: ve-registered-target
// RUN: %clang_cc1 -S -emit-llvm -triple ve-unknown-linux-gnu \
// RUN: -ffreestanding %s -o - | FileCheck %s
#include <velintrin.h>
__vr vr1;
void __attribute__((noinline))
test_vld_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vld_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vld.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vld_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vld_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vld_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vld.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vld_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldnc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldnc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldnc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldnc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldnc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldnc_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldu_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldu_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldu.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldu_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldu_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldu_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldu.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldu_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldunc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldunc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldunc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldunc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldunc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldunc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldunc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldunc_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldlsx_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldlsx_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldlsx.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldlsx_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldlsx_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldlsx_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldlsx.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldlsx_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldlsxnc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldlsxnc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldlsxnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldlsxnc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldlsxnc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldlsxnc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldlsxnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldlsxnc_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldlzx_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldlzx_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldlzx.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldlzx_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldlzx_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldlzx_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldlzx.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldlzx_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldlzxnc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldlzxnc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldlzxnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldlzxnc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldlzxnc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldlzxnc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldlzxnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldlzxnc_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vld2d_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vld2d_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vld2d.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vld2d_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vld2d_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vld2d_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vld2d.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vld2d_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vld2dnc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vld2dnc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vld2dnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vld2dnc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vld2dnc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vld2dnc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vld2dnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vld2dnc_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldu2d_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldu2d_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldu2d.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldu2d_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldu2d_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldu2d_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldu2d.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldu2d_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldu2dnc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldu2dnc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldu2dnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldu2dnc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldu2dnc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldu2dnc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldu2dnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldu2dnc_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldl2dsx_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dsx_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dsx.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldl2dsx_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldl2dsx_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dsx_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dsx.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldl2dsx_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldl2dsxnc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dsxnc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dsxnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldl2dsxnc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldl2dsxnc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dsxnc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dsxnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldl2dsxnc_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldl2dzx_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dzx_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dzx.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldl2dzx_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldl2dzx_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dzx_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dzx.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldl2dzx_vssvl(idx, p, vr1, 256);
}
void __attribute__((noinline))
test_vldl2dzxnc_vssl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dzxnc_vssl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dzxnc.vssl(i64 %{{.*}}, i8* %{{.*}}, i32 256)
vr1 = _vel_vldl2dzxnc_vssl(idx, p, 256);
}
void __attribute__((noinline))
test_vldl2dzxnc_vssvl(char* p, long idx) {
// CHECK-LABEL: @test_vldl2dzxnc_vssvl
// CHECK: call <256 x double> @llvm.ve.vl.vldl2dzxnc.vssvl(i64 %{{.*}}, i8* %{{.*}}, <256 x double> %{{.*}}, i32 256)
vr1 = _vel_vldl2dzxnc_vssvl(idx, p, vr1, 256);
}