xref: /freebsd/contrib/llvm-project/llvm/lib/Target/PowerPC/GISel/PPCLegalizerInfo.cpp (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 //===- PPCLegalizerInfo.h ----------------------------------------*- C++ -*-==//
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 //===----------------------------------------------------------------------===//
8 /// \file
9 /// This file implements the targeting of the Machinelegalizer class for PowerPC
10 //===----------------------------------------------------------------------===//
11 
12 #include "PPCLegalizerInfo.h"
13 #include "llvm/Support/Debug.h"
14 
15 #define DEBUG_TYPE "ppc-legalinfo"
16 
17 using namespace llvm;
18 using namespace LegalizeActions;
19 
20 PPCLegalizerInfo::PPCLegalizerInfo(const PPCSubtarget &ST) {
21   using namespace TargetOpcode;
22   const LLT P0 = LLT::pointer(0, 64);
23   const LLT S1 = LLT::scalar(1);
24   const LLT S8 = LLT::scalar(8);
25   const LLT S16 = LLT::scalar(16);
26   const LLT S32 = LLT::scalar(32);
27   const LLT S64 = LLT::scalar(64);
28   getActionDefinitionsBuilder(G_IMPLICIT_DEF).legalFor({S64});
29   getActionDefinitionsBuilder(G_CONSTANT)
30       .legalFor({S32, S64})
31       .clampScalar(0, S64, S64);
32   getActionDefinitionsBuilder({G_ZEXT, G_SEXT, G_ANYEXT})
33       .legalForCartesianProduct({S64}, {S1, S8, S16, S32})
34       .clampScalar(0, S64, S64);
35   getActionDefinitionsBuilder({G_AND, G_OR, G_XOR})
36       .legalFor({S64})
37       .clampScalar(0, S64, S64);
38   getActionDefinitionsBuilder({G_ADD, G_SUB})
39       .legalFor({S64})
40       .clampScalar(0, S64, S64);
41 
42   getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV})
43       .legalFor({S32, S64});
44 
45   getActionDefinitionsBuilder(G_FCMP).legalForCartesianProduct({S1},
46                                                                {S32, S64});
47 
48   getActionDefinitionsBuilder({G_FPTOSI, G_FPTOUI})
49       .legalForCartesianProduct({S64}, {S32, S64});
50 
51   getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
52       .legalForCartesianProduct({S32, S64}, {S64});
53 
54   getActionDefinitionsBuilder({G_LOAD, G_STORE})
55       .legalForTypesWithMemDesc({{S64, P0, S64, 8}, {S32, P0, S32, 4}});
56 
57   getLegacyLegalizerInfo().computeTables();
58 }
59