Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 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 | |
Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/IndexedMap.h" |
Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" |
Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/RuntimeLibcalls.h" |
| 20 | #include "llvm/IR/Instructions.h" |
Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | |
Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 24 | class ARMSubtarget; |
Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 25 | |
| 26 | /// This class provides the information for the target register banks. |
| 27 | class ARMLegalizerInfo : public LegalizerInfo { |
| 28 | public: |
Diana Picus | 7cab078 | 2017-02-17 11:25:17 +0000 | [diff] [blame] | 29 | ARMLegalizerInfo(const ARMSubtarget &ST); |
Diana Picus | f53865d | 2017-04-24 09:12:19 +0000 | [diff] [blame] | 30 | |
| 31 | bool legalizeCustom(MachineInstr &MI, MachineRegisterInfo &MRI, |
| 32 | MachineIRBuilder &MIRBuilder) const override; |
Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | void setFCmpLibcallsGNU(); |
| 36 | void setFCmpLibcallsAEABI(); |
| 37 | |
| 38 | struct FCmpLibcallInfo { |
| 39 | // Which libcall this is. |
| 40 | RTLIB::Libcall LibcallID; |
| 41 | |
| 42 | // The predicate to be used when comparing the value returned by the |
| 43 | // function with a relevant constant (currently hard-coded to zero). This is |
| 44 | // necessary because often the libcall will return e.g. a value greater than |
| 45 | // 0 to represent 'true' and anything negative to represent 'false', or |
| 46 | // maybe 0 to represent 'true' and non-zero for 'false'. If no comparison is |
| 47 | // needed, this should be CmpInst::BAD_ICMP_PREDICATE. |
| 48 | CmpInst::Predicate Predicate; |
| 49 | }; |
| 50 | using FCmpLibcallsList = SmallVector<FCmpLibcallInfo, 2>; |
| 51 | |
| 52 | // Map from each FCmp predicate to the corresponding libcall infos. A FCmp |
| 53 | // instruction may be lowered to one or two libcalls, which is why we need a |
| 54 | // list. If two libcalls are needed, their results will be OR'ed. |
| 55 | using FCmpLibcallsMapTy = IndexedMap<FCmpLibcallsList>; |
| 56 | |
| 57 | FCmpLibcallsMapTy FCmp32Libcalls; |
Diana Picus | b57bba8 | 2017-07-11 08:50:01 +0000 | [diff] [blame] | 58 | FCmpLibcallsMapTy FCmp64Libcalls; |
Diana Picus | d0104ea | 2017-07-06 09:09:33 +0000 | [diff] [blame] | 59 | |
Diana Picus | b57bba8 | 2017-07-11 08:50:01 +0000 | [diff] [blame] | 60 | // Get the libcall(s) corresponding to \p Predicate for operands of \p Size |
| 61 | // bits. |
| 62 | FCmpLibcallsList getFCmpLibcalls(CmpInst::Predicate, unsigned Size) const; |
Diana Picus | 2227493 | 2016-11-11 08:27:37 +0000 | [diff] [blame] | 63 | }; |
| 64 | } // End llvm namespace. |
| 65 | #endif |