[RISCV][VLOPT] Add vector narrowing integer right shift instructions to isSupportedIn...
[llvm-project.git] / llvm / unittests / CodeGen / GlobalISel / CallLowering.cpp
blob1d36e5e9ca946d3d3ac4653745a08bb42b4f251d
1 //===- CallLowering.cpp - CallLowering unit tests -------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/CodeGen/GlobalISel/CallLowering.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/AsmParser/Parser.h"
12 #include "llvm/IR/LLVMContext.h"
13 #include "llvm/IR/Module.h"
14 #include "llvm/Support/SourceMgr.h"
15 #include "gtest/gtest.h"
17 using namespace llvm;
19 namespace {
20 struct TargetCallLoweringTest : public CallLowering, testing::Test {
21 LLVMContext C;
23 public:
24 TargetCallLoweringTest() : CallLowering(nullptr) {}
26 std::unique_ptr<Module> parseIR(const char *IR) {
27 SMDiagnostic Err;
28 std::unique_ptr<Module> Mod = parseAssemblyString(IR, Err, C);
29 if (!Mod)
30 Err.print("TestTargetCallLoweringTest", errs());
31 return Mod;
34 } // namespace
36 TEST_F(TargetCallLoweringTest, ArgByRef) {
37 std::unique_ptr<Module> M = parseIR(R"(
38 define void @foo(ptr %p0, ptr byref(i32) align(4) %p1) {
39 ret void
41 )");
42 const DataLayout &DL = M->getDataLayout();
43 Function *F = M->getFunction("foo");
44 // Dummy vregs.
45 SmallVector<Register, 4> VRegs(1, 1);
47 CallLowering::ArgInfo Arg0(VRegs, F->getArg(0)->getType(), 0);
48 setArgFlags(Arg0, AttributeList::FirstArgIndex + 0, DL, *F);
49 EXPECT_TRUE(Arg0.Flags[0].isPointer());
50 EXPECT_FALSE(Arg0.Flags[0].isByRef());
52 CallLowering::ArgInfo Arg1(VRegs, F->getArg(1)->getType(), 1);
53 setArgFlags(Arg1, AttributeList::FirstArgIndex + 1, DL, *F);
54 EXPECT_TRUE(Arg1.Flags[0].isPointer());
55 EXPECT_TRUE(Arg1.Flags[0].isByRef());
56 EXPECT_EQ(Arg1.Flags[0].getByRefSize(), 4U);