]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/ARM/ARMLegalizerInfo.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / ARM / ARMLegalizerInfo.h
1 //===- ARMLegalizerInfo ------------------------------------------*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This file declares the targeting of the Machinelegalizer class for ARM.
11 /// \todo This should be generated by TableGen.
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_LIB_TARGET_ARM_ARMMACHINELEGALIZER_H
15 #define LLVM_LIB_TARGET_ARM_ARMMACHINELEGALIZER_H
16
17 #include "llvm/ADT/IndexedMap.h"
18 #include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
19 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h"
20 #include "llvm/CodeGen/RuntimeLibcalls.h"
21 #include "llvm/IR/Instructions.h"
22
23 namespace llvm {
24
25 class ARMSubtarget;
26
27 /// This class provides the information for the target register banks.
28 class ARMLegalizerInfo : public LegalizerInfo {
29 public:
30   ARMLegalizerInfo(const ARMSubtarget &ST);
31
32   bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI,
33                       MachineIRBuilder &MIRBuilder,
34                       GISelChangeObserver &Observer) const override;
35
36 private:
37   void setFCmpLibcallsGNU();
38   void setFCmpLibcallsAEABI();
39
40   struct FCmpLibcallInfo {
41     // Which libcall this is.
42     RTLIB::Libcall LibcallID;
43
44     // The predicate to be used when comparing the value returned by the
45     // function with a relevant constant (currently hard-coded to zero). This is
46     // necessary because often the libcall will return e.g. a value greater than
47     // 0 to represent 'true' and anything negative to represent 'false', or
48     // maybe 0 to represent 'true' and non-zero for 'false'. If no comparison is
49     // needed, this should be CmpInst::BAD_ICMP_PREDICATE.
50     CmpInst::Predicate Predicate;
51   };
52   using FCmpLibcallsList = SmallVector<FCmpLibcallInfo, 2>;
53
54   // Map from each FCmp predicate to the corresponding libcall infos. A FCmp
55   // instruction may be lowered to one or two libcalls, which is why we need a
56   // list. If two libcalls are needed, their results will be OR'ed.
57   using FCmpLibcallsMapTy = IndexedMap<FCmpLibcallsList>;
58
59   FCmpLibcallsMapTy FCmp32Libcalls;
60   FCmpLibcallsMapTy FCmp64Libcalls;
61
62   // Get the libcall(s) corresponding to \p Predicate for operands of \p Size
63   // bits.
64   FCmpLibcallsList getFCmpLibcalls(CmpInst::Predicate, unsigned Size) const;
65 };
66 } // End llvm namespace.
67 #endif