1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===- llvm/Target/TargetLowering.h - Target Lowering Info ------*- C++ -*-===//
2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//                     The LLVM Compiler Infrastructure
4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source
6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details.
7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// \file
11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This file describes how to lower LLVM code to machine code.  This has two
12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// main components:
13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///  1. Which ValueTypes are natively supported by the target.
15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///  2. Which operations are supported for supported ValueTypes.
16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///  3. Cost thresholds for alternative implementations of certain operations.
17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// In addition it has a few other components, like information about FP
19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// immediates.
20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_TARGET_TARGETLOWERING_H
24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_TARGET_TARGETLOWERING_H
25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/APInt.h"
27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/ArrayRef.h"
28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/DenseMap.h"
29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/STLExtras.h"
30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/SmallVector.h"
31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h"
32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/DAGCombine.h"
33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/ISDOpcodes.h"
34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/MachineValueType.h"
35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/RuntimeLibcalls.h"
36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/SelectionDAG.h"
37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/SelectionDAGNodes.h"
38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/ValueTypes.h"
39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/Attributes.h"
40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/CallSite.h"
41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/CallingConv.h"
42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/DataLayout.h"
43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/DerivedTypes.h"
44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/Function.h"
45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/IRBuilder.h"
46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/InlineAsm.h"
47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/Instruction.h"
48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/Instructions.h"
49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/IR/Type.h"
50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/MCRegisterInfo.h"
51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/AtomicOrdering.h"
52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Casting.h"
53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/ErrorHandling.h"
54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Target/TargetCallingConv.h"
55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Target/TargetMachine.h"
56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <algorithm>
57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cassert>
58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <climits>
59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cstdint>
60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <iterator>
61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <map>
62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <string>
63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <utility>
64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <vector>
65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm {
67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass BranchProbability;
69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass CCState;
70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass CCValAssign;
71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Constant;
72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass FastISel;
73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass FunctionLoweringInfo;
74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass GlobalValue;
75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass IntrinsicInst;
76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotstruct KnownBits;
77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass LLVMContext;
78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineBasicBlock;
79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineFunction;
80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineInstr;
81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineJumpTableInfo;
82c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineLoop;
83c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineRegisterInfo;
84c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCContext;
85c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCExpr;
86c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Module;
87c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetRegisterClass;
88c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetLibraryInfo;
89c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetRegisterInfo;
90c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass Value;
91c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
92c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace Sched {
93c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
94c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum Preference {
95c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    None,             // No preference
96c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Source,           // Follow source order.
97c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    RegPressure,      // Scheduling for lowest register pressure.
98c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Hybrid,           // Scheduling for both latency and register pressure.
99c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ILP,              // Scheduling for ILP in low register pressure mode.
100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    VLIW              // Scheduling for VLIW targets.
101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace Sched
104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This base class for TargetLowering contains the SelectionDAG-independent
106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// parts that can be used from the rest of CodeGen.
107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetLoweringBase {
108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This enum indicates whether operations are valid for a target, and if not,
110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// what action should be used to make them valid.
111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum LegalizeAction : uint8_t {
112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Legal,      // The target natively supports this operation.
113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Promote,    // This operation should be executed in a larger type.
114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Expand,     // Try to expand this to other ops, otherwise use a libcall.
115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LibCall,    // Don't try to expand this to other ops, always use a libcall.
116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Custom      // Use the LowerOperation hook to implement custom lowering.
117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This enum indicates whether a types are legal for a target, and if not,
120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// what action should be used to make them valid.
121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum LegalizeTypeAction : uint8_t {
122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypeLegal,           // The target natively supports this type.
123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypePromoteInteger,  // Replace this integer with a larger one.
124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypeExpandInteger,   // Split this integer into two of half the size.
125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypeSoftenFloat,     // Convert this float to a same size integer type,
126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                         // if an operation is not supported in target HW.
127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypeExpandFloat,     // Split this float into two of half the size.
128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypeScalarizeVector, // Replace this one-element vector with its element.
129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypeSplitVector,     // Split this vector into two of half the size.
130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypeWidenVector,     // This vector should be widened into a larger vector.
131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TypePromoteFloat     // Replace this float with a larger one.
132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// LegalizeKind holds the legalization kind that needs to happen to EVT
135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// in order to type-legalize it.
136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  using LegalizeKind = std::pair<LegalizeTypeAction, EVT>;
137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Enum that describes how the target represents true/false values.
139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum BooleanContent {
140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    UndefinedBooleanContent,    // Only bit 0 counts, the rest can hold garbage.
141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ZeroOrOneBooleanContent,        // All bits zero except for bit 0.
142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ZeroOrNegativeOneBooleanContent // All bits equal to bit 0.
143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Enum that describes what type of support for selects the target has.
146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum SelectSupportKind {
147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ScalarValSelect,      // The target supports scalar selects (ex: cmov).
148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ScalarCondVectorVal,  // The target supports selects with a scalar condition
149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          // and vector values (ex: cmov).
150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    VectorMaskSelect      // The target supports vector selects with a vector
151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          // mask (ex: x86 blends).
152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Enum that specifies what an atomic load/AtomicRMWInst is expanded
155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to, if at all. Exists because different targets have different levels of
156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// support for these atomic instructions, and also have different options
157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// w.r.t. what they should expand to.
158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum class AtomicExpansionKind {
159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    None,    // Don't expand the instruction.
160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LLSC,    // Expand the instruction into loadlinked/storeconditional; used
161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot             // by ARM/AArch64.
162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LLOnly,  // Expand the (load) instruction into just a load-linked, which has
163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot             // greater atomic guarantees than a normal load.
164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CmpXChg, // Expand the instruction into cmpxchg; used by at least X86.
165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Enum that specifies when a multiplication should be expanded.
168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum class MulExpansionKind {
169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Always,            // Always expand the instruction.
170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    OnlyLegalOrCustom, // Only expand when the resulting instructions are legal
171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                       // or custom.
172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class ArgListEntry {
175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  public:
176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Value *Val = nullptr;
177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue Node = SDValue();
178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Type *Ty = nullptr;
179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsSExt : 1;
180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsZExt : 1;
181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsInReg : 1;
182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsSRet : 1;
183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsNest : 1;
184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsByVal : 1;
185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsInAlloca : 1;
186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsReturned : 1;
187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsSwiftSelf : 1;
188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsSwiftError : 1;
189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint16_t Alignment = 0;
190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ArgListEntry()
192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        : IsSExt(false), IsZExt(false), IsInReg(false), IsSRet(false),
193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          IsNest(false), IsByVal(false), IsInAlloca(false), IsReturned(false),
194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          IsSwiftSelf(false), IsSwiftError(false) {}
195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setAttributes(ImmutableCallSite *CS, unsigned ArgIdx);
197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  using ArgListTy = std::vector<ArgListEntry>;
199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void markLibCallAttributes(MachineFunction *MF, unsigned CC,
201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     ArgListTy &Args) const {};
202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static ISD::NodeType getExtendForContent(BooleanContent Content) {
204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    switch (Content) {
205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case UndefinedBooleanContent:
206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      // Extend by adding rubbish bits.
207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return ISD::ANY_EXTEND;
208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ZeroOrOneBooleanContent:
209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      // Extend by adding zero bits.
210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return ISD::ZERO_EXTEND;
211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ZeroOrNegativeOneBooleanContent:
212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      // Extend by copying the sign bit.
213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return ISD::SIGN_EXTEND;
214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Invalid content kind");
216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// NOTE: The TargetMachine owns TLOF.
219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  explicit TargetLoweringBase(const TargetMachine &TM);
220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  TargetLoweringBase(const TargetLoweringBase &) = delete;
221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  TargetLoweringBase &operator=(const TargetLoweringBase &) = delete;
222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual ~TargetLoweringBase() = default;
223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Initialize all of the actions to default values.
226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void initActions();
227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const TargetMachine &getTargetMachine() const { return TM; }
230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool useSoftFloat() const { return false; }
232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the pointer type for the given address space, defaults to
234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the pointer type from the data layout.
235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// FIXME: The default needs to be removed once all the code is updated.
236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT getPointerTy(const DataLayout &DL, uint32_t AS = 0) const {
237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the type for frame index, which is determined by
241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the alloca address space specified through the data layout.
242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT getFrameIndexTy(const DataLayout &DL) const {
243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getPointerTy(DL, DL.getAllocaAddrSpace());
244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the type for operands of fence.
247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// TODO: Let fence operands be of i32 type and remove this.
248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MVT getFenceOperandTy(const DataLayout &DL) const {
249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getPointerTy(DL);
250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// EVT is not used in-tree, but is used by out-of-tree target.
253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// A documentation for this function would be nice...
254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MVT getScalarShiftAmountTy(const DataLayout &, EVT) const;
255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  EVT getShiftAmountTy(EVT LHSTy, const DataLayout &DL) const;
257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the type to be used for the index operand of:
259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT,
260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ISD::INSERT_SUBVECTOR, and ISD::EXTRACT_SUBVECTOR
261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MVT getVectorIdxTy(const DataLayout &DL) const {
262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getPointerTy(DL);
263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSelectSupported(SelectSupportKind /*kind*/) const {
266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if multiple condition registers are available.
270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasMultipleConditionRegisters() const {
271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return HasMultipleConditionRegisters;
272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target has BitExtract instructions.
275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasExtractBitsInsn() const { return HasExtractBitsInsn; }
276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the preferred vector type legalization action.
278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual TargetLoweringBase::LegalizeTypeAction
279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getPreferredVectorAction(EVT VT) const {
280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // The default action for one element vectors is to scalarize
281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.getVectorNumElements() == 1)
282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return TypeScalarizeVector;
283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // The default action for other vectors is to promote
284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return TypePromoteInteger;
285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // There are two general methods for expanding a BUILD_VECTOR node:
288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //  1. Use SCALAR_TO_VECTOR on the defined scalar values and then shuffle
289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //     them together.
290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //  2. Build the vector on the stack and then load it.
291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // If this function returns true, then method (1) will be used, subject to
292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // the constraint that all of the necessary shuffles are legal (as determined
293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // by isShuffleMaskLegal). If this function returns false, then method (2) is
294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // always used. The vector type, and the number of defined values, are
295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // provided.
296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool
297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  shouldExpandBuildVectorWithShuffles(EVT /* VT */,
298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      unsigned DefinedValues) const {
299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return DefinedValues < 3;
300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if integer divide is usually cheaper than a sequence of
303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// several shifts, adds, and multiplies for this target.
304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The definition of "cheaper" may depend on whether we're optimizing
305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for speed or for size.
306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isIntDivCheap(EVT VT, AttributeList Attr) const { return false; }
307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target can handle a standalone remainder operation.
309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool hasStandaloneRem(EVT VT) const {
310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if SQRT(X) shouldn't be replaced with X*RSQRT(X).
314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isFsqrtCheap(SDValue X, SelectionDAG &DAG) const {
315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Default behavior is to replace SQRT(X) with X*RSQRT(X).
316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Reciprocal estimate status values used by the functions below.
320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum ReciprocalEstimate : int {
321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Unspecified = -1,
322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Disabled = 0,
323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Enabled = 1
324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return a ReciprocalEstimate enum value for a square root of the given type
327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// based on the function's attributes. If the operation is not overridden by
328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the function's attributes, "Unspecified" is returned and target defaults
329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// are expected to be used for instruction selection.
330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int getRecipEstimateSqrtEnabled(EVT VT, MachineFunction &MF) const;
331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return a ReciprocalEstimate enum value for a division of the given type
333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// based on the function's attributes. If the operation is not overridden by
334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the function's attributes, "Unspecified" is returned and target defaults
335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// are expected to be used for instruction selection.
336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int getRecipEstimateDivEnabled(EVT VT, MachineFunction &MF) const;
337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the refinement step count for a square root of the given type based
339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// on the function's attributes. If the operation is not overridden by
340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the function's attributes, "Unspecified" is returned and target defaults
341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// are expected to be used for instruction selection.
342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int getSqrtRefinementSteps(EVT VT, MachineFunction &MF) const;
343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the refinement step count for a division of the given type based
345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// on the function's attributes. If the operation is not overridden by
346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the function's attributes, "Unspecified" is returned and target defaults
347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// are expected to be used for instruction selection.
348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int getDivRefinementSteps(EVT VT, MachineFunction &MF) const;
349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if target has indicated at least one type should be bypassed.
351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isSlowDivBypassed() const { return !BypassSlowDivWidths.empty(); }
352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns map of slow types for division or remainder with corresponding
354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// fast types
355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const DenseMap<unsigned int, unsigned int> &getBypassSlowDivWidths() const {
356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return BypassSlowDivWidths;
357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if Flow Control is an expensive operation that should be
360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// avoided.
361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isJumpExpensive() const { return JumpIsExpensive; }
362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if selects are only cheaper than branches if the branch is
364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// unlikely to be predicted right.
365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isPredictableSelectExpensive() const {
366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return PredictableSelectIsExpensive;
367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If a branch or a select condition is skewed in one direction by more than
370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// this factor, it is very likely to be predicted correctly.
371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual BranchProbability getPredictableBranchThreshold() const;
372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the following transform is beneficial:
374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// fold (conv (load x)) -> (load (conv*)x)
375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// On architectures that don't natively support some vector loads
376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// efficiently, casting the load to a smaller vector of larger types and
377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// loading is more efficient, however, this can be undone by optimizations in
378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// dag combiner.
379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isLoadBitCastBeneficial(EVT LoadVT,
380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       EVT BitcastVT) const {
381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Don't do if we could do an indexed load on the original type, but not on
382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // the new one.
383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (!LoadVT.isSimple() || !BitcastVT.isSimple())
384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return true;
385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MVT LoadMVT = LoadVT.getSimpleVT();
387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Don't bother doing this if it's just going to be promoted again later, as
389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // doing so might interfere with other combines.
390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (getOperationAction(ISD::LOAD, LoadMVT) == Promote &&
391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        getTypeToPromoteTo(ISD::LOAD, LoadMVT) == BitcastVT.getSimpleVT())
392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return false;
393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the following transform is beneficial:
398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (store (y (conv x)), y*)) -> (store x, (x*))
399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isStoreBitCastBeneficial(EVT StoreVT, EVT BitcastVT) const {
400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Default to the same logic as loads.
401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isLoadBitCastBeneficial(StoreVT, BitcastVT);
402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if it is expected to be cheaper to do a store of a non-zero
405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// vector constant with the given size and type for the address space than to
406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store the individual scalar element constants.
407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool storeOfVectorConstantIsCheap(EVT MemVT,
408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            unsigned NumElem,
409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            unsigned AddrSpace) const {
410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Allow store merging after legalization in addition to before legalization.
414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This may catch stores that do not exist earlier (eg, stores created from
415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// intrinsics).
416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool mergeStoresAfterLegalization() const { return false; }
417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns if it's reasonable to merge stores to MemVT size.
419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool canMergeStoresTo(unsigned AS, EVT MemVT,
420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                const SelectionDAG &DAG) const {
421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return true if it is cheap to speculate a call to intrinsic cttz.
425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isCheapToSpeculateCttz() const {
426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return true if it is cheap to speculate a call to intrinsic ctlz.
430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isCheapToSpeculateCtlz() const {
431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return true if ctlz instruction is fast.
435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isCtlzFast() const {
436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if it is safe to transform an integer-domain bitwise operation
440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// into the equivalent floating-point operation. This should be set to true
441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// if the target has IEEE-754-compliant fabs/fneg operations for the input
442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type.
443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool hasBitPreservingFPLogic(EVT VT) const {
444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return true if it is cheaper to split the store of a merged int val
448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// from a pair of smaller values into multiple stores.
449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isMultiStoresCheaperThanBitsMerge(EVT LTy, EVT HTy) const {
450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return if the target supports combining a
454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// chain like:
455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \code
456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   %andResult = and %val1, #mask
457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   %icmpResult = icmp %andResult, 0
458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \endcode
459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// into a single machine instruction of a form like:
460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \code
461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   cc = test %register, #mask
462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \endcode
463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const {
464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Use bitwise logic to make pairs of compares more efficient. For example:
468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// and (seteq A, B), (seteq C, D) --> seteq (or (xor A, B), (xor C, D)), 0
469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This should be true when it takes more than one instruction to lower
470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// setcc (cmp+set on x86 scalar), when bitwise ops are faster than logic on
471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// condition bits (crand on PowerPC), and/or when reducing cmp+br is a win.
472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool convertSetCCLogicToBitwiseLogic(EVT VT) const {
473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the preferred operand type if the target has a quick way to compare
477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// integer values of the given size. Assume that any legal integer type can
478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// be compared efficiently. Targets may override this to allow illegal wide
479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// types to return a vector type if there is support to compare that type.
480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MVT hasFastEqualityCompare(unsigned NumBits) const {
481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MVT VT = MVT::getIntegerVT(NumBits);
482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isTypeLegal(VT) ? VT : MVT::INVALID_SIMPLE_VALUE_TYPE;
483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target should transform:
486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (X & Y) == Y ---> (~X & Y) == 0
487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (X & Y) != Y ---> (~X & Y) != 0
488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This may be profitable if the target has a bitwise and-not operation that
490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// sets comparison flags. A target may want to limit the transformation based
491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// on the type of Y or if Y is a constant.
492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Note that the transform will not occur if Y is known to be a power-of-2
494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// because a mask and compare of a single bit can be handled by inverting the
495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// predicate, for example:
496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (X & 8) == 8 ---> (X & 8) != 0
497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool hasAndNotCompare(SDValue Y) const {
498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target has a bitwise and-not operation:
502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// X = ~A & B
503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This can be used to simplify select or other instructions.
504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool hasAndNot(SDValue X) const {
505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // If the target has the more complex version of this operation, assume that
506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // it has this operation too.
507c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return hasAndNotCompare(X);
508c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
509c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
510c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return true if the target wants to use the optimization that
511c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// turns ext(promotableInst1(...(promotableInstN(load)))) into
512c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// promotedInst1(...(promotedInstN(ext(load)))).
513c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool enableExtLdPromotion() const { return EnableExtLdPromotion; }
514c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
515c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target can combine store(extractelement VectorTy,
516c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Idx).
517c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p Cost[out] gives the cost of that transformation when this is true.
518c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool canCombineStoreAndExtract(Type *VectorTy, Value *Idx,
519c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                         unsigned &Cost) const {
520c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
521c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
522c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
523c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if target supports floating point exceptions.
524c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasFloatingPointExceptions() const {
525c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return HasFloatingPointExceptions;
526c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
527c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
528c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if target always beneficiates from combining into FMA for a
529c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// given value type. This must typically return false on targets where FMA
530c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// takes more cycles to execute than FADD.
531c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool enableAggressiveFMAFusion(EVT VT) const {
532c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
533c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
534c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
535c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the ValueType of the result of SETCC operations.
536c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
537c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                 EVT VT) const;
538c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
539c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the ValueType for comparison libcalls. Comparions libcalls include
540c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// floating point comparion calls, and Ordered/Unordered check calls on
541c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// floating point numbers.
542c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual
543c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT::SimpleValueType getCmpLibcallReturnType() const;
544c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
545c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For targets without i1 registers, this gives the nature of the high-bits
546c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// of boolean values held in types wider than i1.
547c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
548c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// "Boolean values" are special true/false values produced by nodes like
549c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// SETCC and consumed (as the condition) by nodes like SELECT and BRCOND.
550c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Not to be confused with general values promoted from i1.  Some cpus
551c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// distinguish between vectors of boolean and scalars; the isVec parameter
552c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// selects between the two kinds.  For example on X86 a scalar boolean should
553c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// be zero extended from i1, while the elements of a vector of booleans
554c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// should be sign extended from i1.
555c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
556c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Some cpus also treat floating point types the same way as they treat
557c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// vectors instead of the way they treat scalars.
558c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  BooleanContent getBooleanContents(bool isVec, bool isFloat) const {
559c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (isVec)
560c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return BooleanVectorContents;
561c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isFloat ? BooleanFloatContents : BooleanContents;
562c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
563c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
564c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  BooleanContent getBooleanContents(EVT Type) const {
565c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getBooleanContents(Type.isVector(), Type.isFloatingPoint());
566c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
567c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
568c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return target scheduling preference.
569c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Sched::Preference getSchedulingPreference() const {
570c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return SchedPreferenceInfo;
571c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
572c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
573c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Some scheduler, e.g. hybrid, can switch to different scheduling heuristics
574c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for different nodes. This function returns the preference (or none) for
575c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the given node.
576c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Sched::Preference getSchedulingPreference(SDNode *) const {
577c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return Sched::None;
578c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
579c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
580c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the register class that should be used for the specified value
581c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type.
582c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const TargetRegisterClass *getRegClassFor(MVT VT) const {
583c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const TargetRegisterClass *RC = RegClassForVT[VT.SimpleTy];
584c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(RC && "This value type is not natively supported!");
585c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return RC;
586c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
587c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
588c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the 'representative' register class for the specified value
589c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type.
590c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
591c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The 'representative' register class is the largest legal super-reg
592c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register class for the register class of the value type.  For example, on
593c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// i386 the rep register class for i8, i16, and i32 are GR32; while the rep
594c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register class is GR64 on x86_64.
595c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const TargetRegisterClass *getRepRegClassFor(MVT VT) const {
596c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const TargetRegisterClass *RC = RepRegClassForVT[VT.SimpleTy];
597c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return RC;
598c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
599c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
600c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the cost of the 'representative' register class for the specified
601c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// value type.
602c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual uint8_t getRepRegClassCostFor(MVT VT) const {
603c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return RepRegClassCostForVT[VT.SimpleTy];
604c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
605c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
606c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target has native support for the specified value type.
607c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This means that it has a register that directly holds it without
608c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// promotions or expansions.
609c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isTypeLegal(EVT VT) const {
610c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(!VT.isSimple() ||
611c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           (unsigned)VT.getSimpleVT().SimpleTy < array_lengthof(RegClassForVT));
612c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return VT.isSimple() && RegClassForVT[VT.getSimpleVT().SimpleTy] != nullptr;
613c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
614c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
615c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  class ValueTypeActionImpl {
616c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// ValueTypeActions - For each value type, keep a LegalizeTypeAction enum
617c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// that indicates how instruction selection should deal with the type.
618c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LegalizeTypeAction ValueTypeActions[MVT::LAST_VALUETYPE];
619c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
620c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  public:
621c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ValueTypeActionImpl() {
622c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      std::fill(std::begin(ValueTypeActions), std::end(ValueTypeActions),
623c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                TypeLegal);
624c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
625c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
626c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LegalizeTypeAction getTypeAction(MVT VT) const {
627c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return ValueTypeActions[VT.SimpleTy];
628c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
629c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
630c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void setTypeAction(MVT VT, LegalizeTypeAction Action) {
631c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      ValueTypeActions[VT.SimpleTy] = Action;
632c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
633c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
634c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
635c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const ValueTypeActionImpl &getValueTypeActions() const {
636c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return ValueTypeActions;
637c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
638c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
639c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return how we should legalize values of this type, either it is already
640c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// legal (return 'Legal') or we need to promote it to a larger type (return
641c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// 'Promote'), or we need to expand it into multiple registers of smaller
642c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// integer type (return 'Expand').  'Custom' is not an option.
643c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const {
644c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getTypeConversion(Context, VT).first;
645c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
646c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeTypeAction getTypeAction(MVT VT) const {
647c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return ValueTypeActions.getTypeAction(VT);
648c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
649c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
650c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For types supported by the target, this is an identity function.  For
651c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// types that must be promoted to larger types, this returns the larger type
652c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to promote to.  For integer types that are larger than the largest integer
653c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register, this contains one step in the expansion to get to the smaller
654c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register. For illegal floating point types, this returns the integer type
655c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to transform to.
656c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const {
657c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getTypeConversion(Context, VT).second;
658c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
659c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
660c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For types supported by the target, this is an identity function.  For
661c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// types that must be expanded (i.e. integer types that are larger than the
662c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// largest integer register or illegal floating point types), this returns
663c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the largest legal type it will be expanded to.
664c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  EVT getTypeToExpandTo(LLVMContext &Context, EVT VT) const {
665c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(!VT.isVector());
666c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    while (true) {
667c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      switch (getTypeAction(Context, VT)) {
668c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      case TypeLegal:
669c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        return VT;
670c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      case TypeExpandInteger:
671c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        VT = getTypeToTransformTo(Context, VT);
672c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        break;
673c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      default:
674c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        llvm_unreachable("Type is not legal nor is it to be expanded!");
675c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      }
676c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
677c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
678c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
679c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Vector types are broken down into some number of legal first class types.
680c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For example, EVT::v8f32 maps to 2 EVT::v4f32 with Altivec or SSE1, or 8
681c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// promoted EVT::f64 values with the X86 FP stack.  Similarly, EVT::v2i64
682c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// turns into 4 EVT::i32 values with both PPC and X86.
683c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
684c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method returns the number of registers needed, and the VT for each
685c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register.  It also returns the VT and quantity of the intermediate values
686c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// before they are promoted/expanded.
687c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getVectorTypeBreakdown(LLVMContext &Context, EVT VT,
688c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  EVT &IntermediateVT,
689c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  unsigned &NumIntermediates,
690c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  MVT &RegisterVT) const;
691c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
692c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Certain targets such as MIPS require that some types such as vectors are
693c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// always broken down into scalars in some contexts. This occurs even if the
694c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// vector type is legal.
695c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getVectorTypeBreakdownForCallingConv(
696c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      LLVMContext &Context, EVT VT, EVT &IntermediateVT,
697c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned &NumIntermediates, MVT &RegisterVT) const {
698c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getVectorTypeBreakdown(Context, VT, IntermediateVT, NumIntermediates,
699c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  RegisterVT);
700c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
701c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
702c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  struct IntrinsicInfo {
703c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned     opc = 0;          // target opcode
704c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    EVT          memVT;            // memory VT
705c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const Value* ptrVal = nullptr; // value representing memory location
706c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    int          offset = 0;       // offset off of ptrVal
707c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned     size = 0;         // the size of the memory location
708c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                   // (taken from memVT if zero)
709c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned     align = 1;        // alignment
710c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool         vol = false;      // is volatile?
711c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool         readMem = false;  // reads memory?
712c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool         writeMem = false; // writes memory?
713c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
714c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    IntrinsicInfo() = default;
715c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
716c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
717c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Given an intrinsic, checks if on the target the intrinsic will need to map
718c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to a MemIntrinsicNode (touches memory). If this is the case, it returns
719c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// true and store the intrinsic information into the IntrinsicInfo that was
720c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// passed to the function.
721c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool getTgtMemIntrinsic(IntrinsicInfo &, const CallInst &,
722c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  unsigned /*Intrinsic*/) const {
723c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
724c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
725c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
726c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if the target can instruction select the specified FP
727c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// immediate natively. If false, the legalizer will materialize the FP
728c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// immediate as a load from a constant pool.
729c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isFPImmLegal(const APFloat &/*Imm*/, EVT /*VT*/) const {
730c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
731c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
732c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
733c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets can use this to indicate that they only support *some*
734c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// VECTOR_SHUFFLE operations, those with specific masks.  By default, if a
735c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target supports the VECTOR_SHUFFLE node, all mask values are assumed to be
736c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// legal.
737c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isShuffleMaskLegal(ArrayRef<int> /*Mask*/, EVT /*VT*/) const {
738c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
739c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
740c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
741c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if the operation can trap for the value type.
742c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
743c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// VT must be a legal type. By default, we optimistically assume most
744c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operations don't trap except for integer divide and remainder.
745c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool canOpTrap(unsigned Op, EVT VT) const;
746c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
747c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Similar to isShuffleMaskLegal. This is used by Targets can use this to
748c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// indicate if there is a suitable VECTOR_SHUFFLE that can be used to replace
749c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// a VAND with a constant pool entry.
750c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isVectorClearMaskLegal(const SmallVectorImpl<int> &/*Mask*/,
751c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      EVT /*VT*/) const {
752c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
753c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
754c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
755c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return how this operation should be treated: either it is legal, needs to
756c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// be promoted to a larger size, needs to be expanded to some other code
757c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// sequence, or the target has a custom expander for it.
758c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction getOperationAction(unsigned Op, EVT VT) const {
759c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.isExtended()) return Expand;
760c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // If a target-specific SDNode requires legalization, require the target
761c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // to provide custom legalization for it.
762c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (Op >= array_lengthof(OpActions[0])) return Custom;
763c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return OpActions[(unsigned)VT.getSimpleVT().SimpleTy][Op];
764c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
765c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
766c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified operation is legal on this target or can be
767c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// made legal with custom lowering. This is used to help guide high-level
768c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// lowering decisions.
769c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isOperationLegalOrCustom(unsigned Op, EVT VT) const {
770c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (VT == MVT::Other || isTypeLegal(VT)) &&
771c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      (getOperationAction(Op, VT) == Legal ||
772c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot       getOperationAction(Op, VT) == Custom);
773c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
774c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
775c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified operation is legal on this target or can be
776c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// made legal using promotion. This is used to help guide high-level lowering
777c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// decisions.
778c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isOperationLegalOrPromote(unsigned Op, EVT VT) const {
779c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (VT == MVT::Other || isTypeLegal(VT)) &&
780c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      (getOperationAction(Op, VT) == Legal ||
781c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot       getOperationAction(Op, VT) == Promote);
782c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
783c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
784c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified operation is legal on this target or can be
785c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// made legal with custom lowering or using promotion. This is used to help
786c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// guide high-level lowering decisions.
787c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isOperationLegalOrCustomOrPromote(unsigned Op, EVT VT) const {
788c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (VT == MVT::Other || isTypeLegal(VT)) &&
789c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      (getOperationAction(Op, VT) == Legal ||
790c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot       getOperationAction(Op, VT) == Custom ||
791c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot       getOperationAction(Op, VT) == Promote);
792c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
793c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
794c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the operation uses custom lowering, regardless of whether
795c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the type is legal or not.
796c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isOperationCustom(unsigned Op, EVT VT) const {
797c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getOperationAction(Op, VT) == Custom;
798c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
799c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
800c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if lowering to a jump table is allowed.
801c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool areJTsAllowed(const Function *Fn) const {
802c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (Fn->getFnAttribute("no-jump-tables").getValueAsString() == "true")
803c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return false;
804c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
805c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isOperationLegalOrCustom(ISD::BR_JT, MVT::Other) ||
806c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           isOperationLegalOrCustom(ISD::BRIND, MVT::Other);
807c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
808c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
809c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Check whether the range [Low,High] fits in a machine word.
810c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool rangeFitsInWord(const APInt &Low, const APInt &High,
811c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                       const DataLayout &DL) const {
812c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // FIXME: Using the pointer type doesn't seem ideal.
813c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint64_t BW = DL.getPointerSizeInBits();
814c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint64_t Range = (High - Low).getLimitedValue(UINT64_MAX - 1) + 1;
815c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return Range <= BW;
816c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
817c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
818c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if lowering to a jump table is suitable for a set of case
819c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// clusters which may contain \p NumCases cases, \p Range range of values.
820c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// FIXME: This function check the maximum table size and density, but the
821c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// minimum size is not checked. It would be nice if the the minimum size is
822c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// also combined within this function. Currently, the minimum size check is
823c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// performed in findJumpTable() in SelectionDAGBuiler and
824c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// getEstimatedNumberOfCaseClusters() in BasicTTIImpl.
825c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isSuitableForJumpTable(const SwitchInst *SI, uint64_t NumCases,
826c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              uint64_t Range) const {
827c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const bool OptForSize = SI->getParent()->getParent()->optForSize();
828c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const unsigned MinDensity = getMinimumJumpTableDensity(OptForSize);
829c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    const unsigned MaxJumpTableSize =
830c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        OptForSize || getMaximumJumpTableSize() == 0
831c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot            ? UINT_MAX
832c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot            : getMaximumJumpTableSize();
833c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Check whether a range of clusters is dense enough for a jump table.
834c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (Range <= MaxJumpTableSize &&
835c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        (NumCases * 100 >= Range * MinDensity)) {
836c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return true;
837c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
838c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
839c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
840c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
841c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if lowering to a bit test is suitable for a set of case
842c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// clusters which contains \p NumDests unique destinations, \p Low and
843c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p High as its lowest and highest case values, and expects \p NumCmps
844c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// case value comparisons. Check if the number of destinations, comparison
845c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// metric, and range are all suitable.
846c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isSuitableForBitTests(unsigned NumDests, unsigned NumCmps,
847c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                             const APInt &Low, const APInt &High,
848c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                             const DataLayout &DL) const {
849c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // FIXME: I don't think NumCmps is the correct metric: a single case and a
850c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // range of cases both require only one branch to lower. Just looking at the
851c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // number of clusters and destinations should be enough to decide whether to
852c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // build bit tests.
853c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
854c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // To lower a range with bit tests, the range must fit the bitwidth of a
855c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // machine word.
856c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (!rangeFitsInWord(Low, High, DL))
857c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return false;
858c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
859c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Decide whether it's profitable to lower this range with bit tests. Each
860c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // destination requires a bit test and branch, and there is an overall range
861c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // check branch. For a small number of clusters, separate comparisons might
862c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // be cheaper, and for many destinations, splitting the range might be
863c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // better.
864c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (NumDests == 1 && NumCmps >= 3) || (NumDests == 2 && NumCmps >= 5) ||
865c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           (NumDests == 3 && NumCmps >= 6);
866c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
867c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
868c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified operation is illegal on this target or
869c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// unlikely to be made legal with custom lowering. This is used to help guide
870c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// high-level lowering decisions.
871c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isOperationExpand(unsigned Op, EVT VT) const {
872c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (!isTypeLegal(VT) || getOperationAction(Op, VT) == Expand);
873c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
874c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
875c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified operation is legal on this target.
876c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isOperationLegal(unsigned Op, EVT VT) const {
877c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (VT == MVT::Other || isTypeLegal(VT)) &&
878c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           getOperationAction(Op, VT) == Legal;
879c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
880c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
881c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return how this load with extension should be treated: either it is legal,
882c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// needs to be promoted to a larger size, needs to be expanded to some other
883c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// code sequence, or the target has a custom expander for it.
884c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT,
885c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  EVT MemVT) const {
886c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (ValVT.isExtended() || MemVT.isExtended()) return Expand;
887c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned ValI = (unsigned) ValVT.getSimpleVT().SimpleTy;
888c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned MemI = (unsigned) MemVT.getSimpleVT().SimpleTy;
889c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValI < MVT::LAST_VALUETYPE &&
890c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           MemI < MVT::LAST_VALUETYPE && "Table isn't big enough!");
891c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned Shift = 4 * ExtType;
892c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (LegalizeAction)((LoadExtActions[ValI][MemI] >> Shift) & 0xf);
893c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
894c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
895c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified load with extension is legal on this target.
896c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const {
897c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getLoadExtAction(ExtType, ValVT, MemVT) == Legal;
898c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
899c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
900c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified load with extension is legal or custom
901c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// on this target.
902c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isLoadExtLegalOrCustom(unsigned ExtType, EVT ValVT, EVT MemVT) const {
903c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getLoadExtAction(ExtType, ValVT, MemVT) == Legal ||
904c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           getLoadExtAction(ExtType, ValVT, MemVT) == Custom;
905c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
906c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
907c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return how this store with truncation should be treated: either it is
908c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// legal, needs to be promoted to a larger size, needs to be expanded to some
909c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// other code sequence, or the target has a custom expander for it.
910c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction getTruncStoreAction(EVT ValVT, EVT MemVT) const {
911c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (ValVT.isExtended() || MemVT.isExtended()) return Expand;
912c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned ValI = (unsigned) ValVT.getSimpleVT().SimpleTy;
913c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned MemI = (unsigned) MemVT.getSimpleVT().SimpleTy;
914c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(ValI < MVT::LAST_VALUETYPE && MemI < MVT::LAST_VALUETYPE &&
915c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "Table isn't big enough!");
916c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return TruncStoreActions[ValI][MemI];
917c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
918c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
919c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified store with truncation is legal on this
920c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target.
921c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isTruncStoreLegal(EVT ValVT, EVT MemVT) const {
922c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isTypeLegal(ValVT) && getTruncStoreAction(ValVT, MemVT) == Legal;
923c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
924c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
925c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified store with truncation has solution on this
926c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target.
927c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isTruncStoreLegalOrCustom(EVT ValVT, EVT MemVT) const {
928c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isTypeLegal(ValVT) &&
929c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      (getTruncStoreAction(ValVT, MemVT) == Legal ||
930c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot       getTruncStoreAction(ValVT, MemVT) == Custom);
931c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
932c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
933c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return how the indexed load should be treated: either it is legal, needs
934c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to be promoted to a larger size, needs to be expanded to some other code
935c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// sequence, or the target has a custom expander for it.
936c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction
937c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getIndexedLoadAction(unsigned IdxMode, MVT VT) const {
938c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(IdxMode < ISD::LAST_INDEXED_MODE && VT.isValid() &&
939c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "Table isn't big enough!");
940c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned Ty = (unsigned)VT.SimpleTy;
941c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (LegalizeAction)((IndexedModeActions[Ty][IdxMode] & 0xf0) >> 4);
942c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
943c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
944c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified indexed load is legal on this target.
945c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isIndexedLoadLegal(unsigned IdxMode, EVT VT) const {
946c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return VT.isSimple() &&
947c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      (getIndexedLoadAction(IdxMode, VT.getSimpleVT()) == Legal ||
948c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot       getIndexedLoadAction(IdxMode, VT.getSimpleVT()) == Custom);
949c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
950c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
951c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return how the indexed store should be treated: either it is legal, needs
952c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to be promoted to a larger size, needs to be expanded to some other code
953c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// sequence, or the target has a custom expander for it.
954c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction
955c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getIndexedStoreAction(unsigned IdxMode, MVT VT) const {
956c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(IdxMode < ISD::LAST_INDEXED_MODE && VT.isValid() &&
957c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "Table isn't big enough!");
958c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned Ty = (unsigned)VT.SimpleTy;
959c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return (LegalizeAction)(IndexedModeActions[Ty][IdxMode] & 0x0f);
960c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
961c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
962c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified indexed load is legal on this target.
963c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isIndexedStoreLegal(unsigned IdxMode, EVT VT) const {
964c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return VT.isSimple() &&
965c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      (getIndexedStoreAction(IdxMode, VT.getSimpleVT()) == Legal ||
966c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot       getIndexedStoreAction(IdxMode, VT.getSimpleVT()) == Custom);
967c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
968c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
969c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return how the condition code should be treated: either it is legal, needs
970c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to be expanded to some other code sequence, or the target has a custom
971c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// expander for it.
972c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction
973c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getCondCodeAction(ISD::CondCode CC, MVT VT) const {
974c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert((unsigned)CC < array_lengthof(CondCodeActions) &&
975c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           ((unsigned)VT.SimpleTy >> 3) < array_lengthof(CondCodeActions[0]) &&
976c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "Table isn't big enough!");
977c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // See setCondCodeAction for how this is encoded.
978c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint32_t Shift = 4 * (VT.SimpleTy & 0x7);
979c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint32_t Value = CondCodeActions[CC][VT.SimpleTy >> 3];
980c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LegalizeAction Action = (LegalizeAction) ((Value >> Shift) & 0xF);
981c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(Action != Promote && "Can't promote condition code!");
982c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return Action;
983c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
984c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
985c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified condition code is legal on this target.
986c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isCondCodeLegal(ISD::CondCode CC, MVT VT) const {
987c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return
988c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      getCondCodeAction(CC, VT) == Legal ||
989c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      getCondCodeAction(CC, VT) == Custom;
990c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
991c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
992c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the action for this operation is to promote, this method returns the
993c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ValueType to promote to.
994c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT getTypeToPromoteTo(unsigned Op, MVT VT) const {
995c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(getOperationAction(Op, VT) == Promote &&
996c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "This operation isn't promoted!");
997c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
998c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // See if this has an explicit type specified.
999c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::map<std::pair<unsigned, MVT::SimpleValueType>,
1000c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot             MVT::SimpleValueType>::const_iterator PTTI =
1001c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      PromoteToType.find(std::make_pair(Op, VT.SimpleTy));
1002c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (PTTI != PromoteToType.end()) return PTTI->second;
1003c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1004c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert((VT.isInteger() || VT.isFloatingPoint()) &&
1005c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "Cannot autopromote this type, add it with AddPromotedToType.");
1006c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1007c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MVT NVT = VT;
1008c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    do {
1009c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      NVT = (MVT::SimpleValueType)(NVT.SimpleTy+1);
1010c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      assert(NVT.isInteger() == VT.isInteger() && NVT != MVT::isVoid &&
1011c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot             "Didn't find type to promote to!");
1012c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    } while (!isTypeLegal(NVT) ||
1013c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot              getOperationAction(Op, NVT) == Promote);
1014c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return NVT;
1015c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1016c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1017c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the EVT corresponding to this LLVM type.  This is fixed by the LLVM
1018c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operations except for the pointer size.  If AllowUnknown is true, this
1019c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// will return MVT::Other for types with no EVT counterpart (e.g. structs),
1020c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// otherwise it will assert.
1021c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  EVT getValueType(const DataLayout &DL, Type *Ty,
1022c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                   bool AllowUnknown = false) const {
1023c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Lower scalar pointers to native pointer types.
1024c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (PointerType *PTy = dyn_cast<PointerType>(Ty))
1025c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getPointerTy(DL, PTy->getAddressSpace());
1026c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1027c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (Ty->isVectorTy()) {
1028c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      VectorType *VTy = cast<VectorType>(Ty);
1029c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Type *Elm = VTy->getElementType();
1030c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      // Lower vectors of pointers to native pointer types.
1031c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      if (PointerType *PT = dyn_cast<PointerType>(Elm)) {
1032c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        EVT PointerTy(getPointerTy(DL, PT->getAddressSpace()));
1033c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        Elm = PointerTy.getTypeForEVT(Ty->getContext());
1034c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      }
1035c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1036c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false),
1037c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                       VTy->getNumElements());
1038c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1039c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return EVT::getEVT(Ty, AllowUnknown);
1040c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1041c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1042c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the MVT corresponding to this LLVM type. See getValueType.
1043c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT getSimpleValueType(const DataLayout &DL, Type *Ty,
1044c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                         bool AllowUnknown = false) const {
1045c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getValueType(DL, Ty, AllowUnknown).getSimpleVT();
1046c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1047c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1048c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the desired alignment for ByVal or InAlloca aggregate function
1049c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// arguments in the caller parameter area.  This is the actual alignment, not
1050c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// its logarithm.
1051c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getByValTypeAlignment(Type *Ty, const DataLayout &DL) const;
1052c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1053c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the type of registers that this ValueType will eventually require.
1054c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT getRegisterType(MVT VT) const {
1055c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert((unsigned)VT.SimpleTy < array_lengthof(RegisterTypeForVT));
1056c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return RegisterTypeForVT[VT.SimpleTy];
1057c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1058c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1059c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the type of registers that this ValueType will eventually require.
1060c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT getRegisterType(LLVMContext &Context, EVT VT) const {
1061c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.isSimple()) {
1062c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      assert((unsigned)VT.getSimpleVT().SimpleTy <
1063c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                array_lengthof(RegisterTypeForVT));
1064c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return RegisterTypeForVT[VT.getSimpleVT().SimpleTy];
1065c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1066c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.isVector()) {
1067c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      EVT VT1;
1068c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      MVT RegisterVT;
1069c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned NumIntermediates;
1070c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      (void)getVectorTypeBreakdown(Context, VT, VT1,
1071c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                   NumIntermediates, RegisterVT);
1072c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return RegisterVT;
1073c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1074c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.isInteger()) {
1075c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getRegisterType(Context, getTypeToTransformTo(Context, VT));
1076c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1077c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Unsupported extended type!");
1078c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1079c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1080c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the number of registers that this ValueType will eventually
1081c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// require.
1082c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1083c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This is one for any types promoted to live in larger registers, but may be
1084c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// more than one for types (like i64) that are split into pieces.  For types
1085c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// like i140, which are first promoted then expanded, it is the number of
1086c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// registers needed to hold all the bits of the original type.  For an i140
1087c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// on a 32 bit machine this means 5 registers.
1088c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getNumRegisters(LLVMContext &Context, EVT VT) const {
1089c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.isSimple()) {
1090c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      assert((unsigned)VT.getSimpleVT().SimpleTy <
1091c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                array_lengthof(NumRegistersForVT));
1092c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return NumRegistersForVT[VT.getSimpleVT().SimpleTy];
1093c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1094c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.isVector()) {
1095c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      EVT VT1;
1096c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      MVT VT2;
1097c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned NumIntermediates;
1098c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return getVectorTypeBreakdown(Context, VT, VT1, NumIntermediates, VT2);
1099c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (VT.isInteger()) {
1101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned BitWidth = VT.getSizeInBits();
1102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      unsigned RegWidth = getRegisterType(Context, VT).getSizeInBits();
1103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return (BitWidth + RegWidth - 1) / RegWidth;
1104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Unsupported extended type!");
1106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Certain combinations of ABIs, Targets and features require that types
1109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// are legal for some operations and not for other operations.
1110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For MIPS all vector types must be passed through the integer register set.
1111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MVT getRegisterTypeForCallingConv(MVT VT) const {
1112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getRegisterType(VT);
1113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MVT getRegisterTypeForCallingConv(LLVMContext &Context,
1116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            EVT VT) const {
1117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getRegisterType(Context, VT);
1118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Certain targets require unusual breakdowns of certain types. For MIPS,
1121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// this occurs when a vector type is used, as vector are passed through the
1122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// integer register set.
1123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getNumRegistersForCallingConv(LLVMContext &Context,
1124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                 EVT VT) const {
1125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getNumRegisters(Context, VT);
1126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Certain targets have context senstive alignment requirements, where one
1129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type has the alignment requirement of another type.
1130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getABIAlignmentForCallingConv(Type *ArgTy,
1131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                 DataLayout DL) const {
1132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return DL.getABITypeAlignment(ArgTy);
1133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If true, then instruction selection should seek to shrink the FP constant
1136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// of the specified type to a smaller type in order to save space and / or
1137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// reduce runtime.
1138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool ShouldShrinkFPConstant(EVT) const { return true; }
1139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Return true if it is profitable to reduce the given load node to a smaller
1141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // type.
1142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
1143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // e.g. (i16 (trunc (i32 (load x))) -> i16 load x should be performed
1144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldReduceLoadWidth(SDNode *Load,
1145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     ISD::LoadExtType ExtTy,
1146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     EVT NewVT) const {
1147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
1148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// When splitting a value of the specified type into parts, does the Lo
1151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// or Hi part come first?  This usually follows the endianness, except
1152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for ppcf128, where the Hi part always comes first.
1153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasBigEndianPartOrdering(EVT VT, const DataLayout &DL) const {
1154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return DL.isBigEndian() || VT == MVT::ppcf128;
1155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If true, the target has custom DAG combine transformations that it can
1158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// perform for the specified node.
1159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool hasTargetDAGCombine(ISD::NodeType NT) const {
1160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(unsigned(NT >> 3) < array_lengthof(TargetDAGCombineArray));
1161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return TargetDAGCombineArray[NT >> 3] & (1 << (NT&7));
1162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getGatherAllAliasesMaxDepth() const {
1165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return GatherAllAliasesMaxDepth;
1166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the size of the platform's va_list object.
1169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getVaListSizeInBits(const DataLayout &DL) const {
1170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return getPointerTy(DL).getSizeInBits();
1171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Get maximum # of store operations permitted for llvm.memset
1174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This function returns the maximum number of store operations permitted
1176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to replace a call to llvm.memset. The value is set by the target at the
1177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// performance threshold for such a replacement. If OptSize is true,
1178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// return the limit for functions that have OptSize attribute.
1179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMaxStoresPerMemset(bool OptSize) const {
1180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return OptSize ? MaxStoresPerMemsetOptSize : MaxStoresPerMemset;
1181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Get maximum # of store operations permitted for llvm.memcpy
1184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This function returns the maximum number of store operations permitted
1186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to replace a call to llvm.memcpy. The value is set by the target at the
1187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// performance threshold for such a replacement. If OptSize is true,
1188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// return the limit for functions that have OptSize attribute.
1189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMaxStoresPerMemcpy(bool OptSize) const {
1190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return OptSize ? MaxStoresPerMemcpyOptSize : MaxStoresPerMemcpy;
1191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Get maximum # of load operations permitted for memcmp
1194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This function returns the maximum number of load operations permitted
1196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to replace a call to memcmp. The value is set by the target at the
1197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// performance threshold for such a replacement. If OptSize is true,
1198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// return the limit for functions that have OptSize attribute.
1199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMaxExpandSizeMemcmp(bool OptSize) const {
1200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return OptSize ? MaxLoadsPerMemcmpOptSize : MaxLoadsPerMemcmp;
1201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Get maximum # of store operations permitted for llvm.memmove
1204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This function returns the maximum number of store operations permitted
1206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to replace a call to llvm.memmove. The value is set by the target at the
1207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// performance threshold for such a replacement. If OptSize is true,
1208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// return the limit for functions that have OptSize attribute.
1209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMaxStoresPerMemmove(bool OptSize) const {
1210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return OptSize ? MaxStoresPerMemmoveOptSize : MaxStoresPerMemmove;
1211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Determine if the target supports unaligned memory accesses.
1214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This function returns true if the target allows unaligned memory accesses
1216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// of the specified type in the given address space. If true, it also returns
1217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// whether the unaligned memory access is "fast" in the last argument by
1218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// reference. This is used, for example, in situations where an array
1219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// copy/move/set is converted to a sequence of store operations. Its use
1220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// helps to ensure that such replacements don't generate code that causes an
1221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// alignment error (trap) on the target machine.
1222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool allowsMisalignedMemoryAccesses(EVT,
1223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                              unsigned AddrSpace = 0,
1224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                              unsigned Align = 1,
1225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                              bool * /*Fast*/ = nullptr) const {
1226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target supports a memory access of this type for the
1230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// given address space and alignment. If the access is allowed, the optional
1231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// final parameter returns if the access is also fast (as defined by the
1232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target).
1233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT,
1234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          unsigned AddrSpace = 0, unsigned Alignment = 1,
1235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          bool *Fast = nullptr) const;
1236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the target specific optimal type for load and store operations as
1238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// a result of memset, memcpy, and memmove lowering.
1239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If DstAlign is zero that means it's safe to destination alignment can
1241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// satisfy any constraint. Similarly if SrcAlign is zero it means there isn't
1242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// a need to check it against alignment requirement, probably because the
1243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// source does not need to be loaded. If 'IsMemset' is true, that means it's
1244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// expanding a memset. If 'ZeroMemset' is true, that means it's a memset of
1245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// zero. 'MemcpyStrSrc' indicates whether the memcpy source is constant so it
1246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// does not need to be loaded.  It returns EVT::Other if the type should be
1247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// determined using generic target-independent logic.
1248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual EVT getOptimalMemOpType(uint64_t /*Size*/,
1249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  unsigned /*DstAlign*/, unsigned /*SrcAlign*/,
1250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  bool /*IsMemset*/,
1251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  bool /*ZeroMemset*/,
1252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  bool /*MemcpyStrSrc*/,
1253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  MachineFunction &/*MF*/) const {
1254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MVT::Other;
1255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if it's safe to use load / store of the specified type to
1258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// expand memcpy / memset inline.
1259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This is mostly true for all types except for some special cases. For
1261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// example, on X86 targets without SSE2 f64 load / store are done with fldl /
1262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// fstpl which also does type conversion. Note the specified type doesn't
1263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// have to be legal as the hook is used before type legalization.
1264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isSafeMemOpType(MVT /*VT*/) const { return true; }
1265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Determine if we should use _setjmp or setjmp to implement llvm.setjmp.
1267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool usesUnderscoreSetJmp() const {
1268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return UseUnderscoreSetJmp;
1269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Determine if we should use _longjmp or longjmp to implement llvm.longjmp.
1272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool usesUnderscoreLongJmp() const {
1273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return UseUnderscoreLongJmp;
1274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return lower limit for number of blocks in a jump table.
1277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMinimumJumpTableEntries() const;
1278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return lower limit of the density in a jump table.
1280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMinimumJumpTableDensity(bool OptForSize) const;
1281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return upper limit for number of entries in a jump table.
1283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Zero if no limit.
1284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMaximumJumpTableSize() const;
1285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isJumpTableRelative() const {
1287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return TM.isPositionIndependent();
1288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If a physical register, this specifies the register that
1291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// llvm.savestack/llvm.restorestack should save and restore.
1292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getStackPointerRegisterToSaveRestore() const {
1293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return StackPointerRegisterToSaveRestore;
1294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If a physical register, this returns the register that receives the
1297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// exception address on entry to an EH pad.
1298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned
1299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getExceptionPointerRegister(const Constant *PersonalityFn) const {
1300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // 0 is guaranteed to be the NoRegister value on all targets
1301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return 0;
1302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If a physical register, this returns the register that receives the
1305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// exception typeid on entry to a landing pad.
1306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned
1307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getExceptionSelectorRegister(const Constant *PersonalityFn) const {
1308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // 0 is guaranteed to be the NoRegister value on all targets
1309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return 0;
1310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool needsFixedCatchObjects() const {
1313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    report_fatal_error("Funclet EH is not implemented for this target");
1314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the target's jmp_buf size in bytes (if never set, the default is
1317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// 200)
1318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getJumpBufSize() const {
1319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return JumpBufSize;
1320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the target's jmp_buf alignment in bytes (if never set, the default
1323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// is 0)
1324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getJumpBufAlignment() const {
1325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return JumpBufAlignment;
1326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the minimum stack alignment of an argument.
1329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMinStackArgumentAlignment() const {
1330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MinStackArgumentAlignment;
1331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the minimum function alignment.
1334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMinFunctionAlignment() const {
1335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MinFunctionAlignment;
1336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the preferred function alignment.
1339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getPrefFunctionAlignment() const {
1340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return PrefFunctionAlignment;
1341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the preferred loop alignment.
1344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getPrefLoopAlignment(MachineLoop *ML = nullptr) const {
1345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return PrefLoopAlignment;
1346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the target has a standard location for the stack protector guard,
1349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// returns the address of that location. Otherwise, returns nullptr.
1350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// DEPRECATED: please override useLoadStackGuardNode and customize
1351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///             LOAD_STACK_GUARD, or customize @llvm.stackguard().
1352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Value *getIRStackGuard(IRBuilder<> &IRB) const;
1353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Inserts necessary declarations for SSP (stack protection) purpose.
1355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Should be used only when getIRStackGuard returns nullptr.
1356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void insertSSPDeclarations(Module &M) const;
1357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the variable that's previously inserted by insertSSPDeclarations,
1359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// if any, otherwise return nullptr. Should be used only when
1360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// getIRStackGuard returns nullptr.
1361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Value *getSDagStackGuard(const Module &M) const;
1362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the target has a standard stack protection check function that
1364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// performs validation and error handling, returns the function. Otherwise,
1365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// returns nullptr. Must be previously inserted by insertSSPDeclarations.
1366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Should be used only when getIRStackGuard returns nullptr.
1367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Value *getSSPStackGuardCheck(const Module &M) const;
1368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
1370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Value *getDefaultSafeStackPointerLocation(IRBuilder<> &IRB,
1371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            bool UseTLS) const;
1372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
1374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the target-specific address of the unsafe stack pointer.
1375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Value *getSafeStackPointerLocation(IRBuilder<> &IRB) const;
1376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the name of the symbol used to emit stack probes or the empty
1378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// string if not applicable.
1379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual StringRef getStackProbeSymbolName(MachineFunction &MF) const {
1380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return "";
1381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if a cast between SrcAS and DestAS is a noop.
1384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const {
1385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if a cast from SrcAS to DestAS is "cheap", such that e.g. we
1389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// are happy to sink it into basic blocks.
1390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isCheapAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const {
1391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isNoopAddrSpaceCast(SrcAS, DestAS);
1392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the pointer arguments to CI should be aligned by aligning
1395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the object whose address is being passed. If so then MinSize is set to the
1396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// minimum size the object must be to be aligned and PrefAlign is set to the
1397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// preferred alignment.
1398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldAlignPointerArgs(CallInst * /*CI*/, unsigned & /*MinSize*/,
1399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      unsigned & /*PrefAlign*/) const {
1400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
1404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Helpers for TargetTransformInfo implementations
1405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
1406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Get the ISD node that corresponds to the Instruction class opcode.
1408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  int InstructionOpcodeToISD(unsigned Opcode) const;
1409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Estimate the cost of type-legalization and the legalized type.
1411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::pair<int, MVT> getTypeLegalizationCost(const DataLayout &DL,
1412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                              Type *Ty) const;
1413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
1415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
1417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \name Helpers for atomic expansion.
1418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
1419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the maximum atomic operation size (in bits) supported by
1421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the backend. Atomic operations greater than this size (as well
1422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// as ones that are not naturally aligned), will be expanded by
1423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// AtomicExpandPass into an __atomic_* library call.
1424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMaxAtomicSizeInBitsSupported() const {
1425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MaxAtomicSizeInBitsSupported;
1426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns the size of the smallest cmpxchg or ll/sc instruction
1429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the backend supports.  Any smaller operations are widened in
1430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// AtomicExpandPass.
1431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Note that *unlike* operations above the maximum size, atomic ops
1433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// are still natively supported below the minimum; they just
1434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// require a more complex expansion.
1435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned getMinCmpXchgSizeInBits() const { return MinCmpXchgSizeInBits; }
1436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Whether AtomicExpandPass should automatically insert fences and reduce
1438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ordering for this atomic. This should be true for most architectures with
1439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// weak memory ordering. Defaults to false.
1440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldInsertFencesForAtomic(const Instruction *I) const {
1441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Perform a load-linked operation on Addr, returning a "Value *" with the
1445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// corresponding pointee type. This may entail some non-trivial operations to
1446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// truncate or reconstruct types that will be illegal in the backend. See
1447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ARMISelLowering for an example implementation.
1448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
1449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                AtomicOrdering Ord) const {
1450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Load linked unimplemented on this target");
1451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Perform a store-conditional operation to Addr. Return the status of the
1454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store. This should be 0 if the store succeeded, non-zero otherwise.
1455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
1456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      Value *Addr, AtomicOrdering Ord) const {
1457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Store conditional unimplemented on this target");
1458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Inserts in the IR a target-specific intrinsic specifying a fence.
1461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// It is called by AtomicExpandPass before expanding an
1462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   AtomicRMW/AtomicCmpXchg/AtomicStore/AtomicLoad
1463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   if shouldInsertFencesForAtomic returns true.
1464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Inst is the original atomic instruction, prior to other expansions that
1466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// may be performed.
1467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This function should either return a nullptr, or a pointer to an IR-level
1469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   Instruction*. Even complex fence sequences can be represented by a
1470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   single Instruction* through an intrinsic to be lowered later.
1471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Backends should override this method to produce target-specific intrinsic
1472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   for their fences.
1473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// FIXME: Please note that the default implementation here in terms of
1474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   IR-level fences exists for historical/compatibility reasons and is
1475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   *unsound* ! Fences cannot, in general, be used to restore sequential
1476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   consistency. For example, consider the following example:
1477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// atomic<int> x = y = 0;
1478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// int r1, r2, r3, r4;
1479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Thread 0:
1480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   x.store(1);
1481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Thread 1:
1482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   y.store(1);
1483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Thread 2:
1484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   r1 = x.load();
1485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   r2 = y.load();
1486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Thread 3:
1487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   r3 = y.load();
1488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   r4 = x.load();
1489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///  r1 = r3 = 1 and r2 = r4 = 0 is impossible as long as the accesses are all
1490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///  seq_cst. But if they are lowered to monotonic accesses, no amount of
1491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///  IR-level fences can prevent it.
1492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @{
1493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Instruction *emitLeadingFence(IRBuilder<> &Builder, Instruction *Inst,
1494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                        AtomicOrdering Ord) const {
1495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (isReleaseOrStronger(Ord) && Inst->hasAtomicStore())
1496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return Builder.CreateFence(Ord);
1497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    else
1498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return nullptr;
1499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual Instruction *emitTrailingFence(IRBuilder<> &Builder,
1502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                         Instruction *Inst,
1503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                         AtomicOrdering Ord) const {
1504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (isAcquireOrStronger(Ord))
1505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return Builder.CreateFence(Ord);
1506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    else
1507c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return nullptr;
1508c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1509c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
1510c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1511c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Emits code that executes when the comparison result in the ll/sc
1512c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // expansion of a cmpxchg instruction is such that the store-conditional will
1513c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // not execute.  This makes it possible to balance out the load-linked with
1514c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // a dedicated instruction, if desired.
1515c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // E.g., on ARM, if ldrex isn't followed by strex, the exclusive monitor would
1516c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // be unnecessarily held, except if clrex, inserted by this hook, is executed.
1517c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void emitAtomicCmpXchgNoStoreLLBalance(IRBuilder<> &Builder) const {}
1518c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1519c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if the given (atomic) store should be expanded by the
1520c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// IR-level AtomicExpand pass into an "atomic xchg" which ignores its input.
1521c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldExpandAtomicStoreInIR(StoreInst *SI) const {
1522c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1523c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1524c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1525c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if arguments should be sign-extended in lib calls.
1526c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const {
1527c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return IsSigned;
1528c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1529c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1530c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns how the given (atomic) load should be expanded by the
1531c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// IR-level AtomicExpand pass.
1532c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const {
1533c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return AtomicExpansionKind::None;
1534c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1535c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1536c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if the given atomic cmpxchg should be expanded by the
1537c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// IR-level AtomicExpand pass into a load-linked/store-conditional sequence
1538c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (through emitLoadLinked() and emitStoreConditional()).
1539c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const {
1540c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1541c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1542c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1543c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns how the IR-level AtomicExpand pass should expand the given
1544c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// AtomicRMW, if at all. Default is to never expand.
1545c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const {
1546c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return AtomicExpansionKind::None;
1547c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1548c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1549c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// On some platforms, an AtomicRMW that never actually modifies the value
1550c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (such as fetch_add of 0) can be turned into a fence followed by an
1551c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// atomic load. This may sound useless, but it makes it possible for the
1552c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// processor to keep the cacheline shared, dramatically improving
1553c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// performance. And such idempotent RMWs are useful for implementing some
1554c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// kinds of locks, see for example (justification + benchmarks):
1555c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// http://www.hpl.hp.com/techreports/2012/HPL-2012-68.pdf
1556c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method tries doing that transformation, returning the atomic load if
1557c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// it succeeds, and nullptr otherwise.
1558c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If shouldExpandAtomicLoadInIR returns true on that load, it will undergo
1559c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// another round of expansion.
1560c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual LoadInst *
1561c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *RMWI) const {
1562c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return nullptr;
1563c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1564c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1565c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns how the platform's atomic operations are extended (ZERO_EXTEND,
1566c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// SIGN_EXTEND, or ANY_EXTEND).
1567c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual ISD::NodeType getExtendForAtomicOps() const {
1568c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return ISD::ZERO_EXTEND;
1569c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1570c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1571c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// @}
1572c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1573c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if we should normalize
1574c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// select(N0&N1, X, Y) => select(N0, select(N1, X, Y), Y) and
1575c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// select(N0|N1, X, Y) => select(N0, select(N1, X, Y, Y)) if it is likely
1576c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// that it saves us from materializing N0 and N1 in an integer register.
1577c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets that are able to perform and/or on flags should return false here.
1578c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldNormalizeToSelectSequence(LLVMContext &Context,
1579c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                               EVT VT) const {
1580c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // If a target has multiple condition registers, then it likely has logical
1581c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // operations on those registers.
1582c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (hasMultipleConditionRegisters())
1583c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return false;
1584c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Only do the transform if the value won't be split into multiple
1585c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // registers.
1586c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LegalizeTypeAction Action = getTypeAction(Context, VT);
1587c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return Action != TypeExpandInteger && Action != TypeExpandFloat &&
1588c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Action != TypeSplitVector;
1589c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1590c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1591c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if a select of constants (select Cond, C1, C2) should be
1592c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// transformed into simple math ops with the condition value. For example:
1593c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// select Cond, C1, C1-1 --> add (zext Cond), C1-1
1594c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool convertSelectOfConstantsToMath(EVT VT) const {
1595c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1596c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1597c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1598c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
1599c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // TargetLowering Configuration Methods - These methods should be invoked by
1600c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // the derived class constructor to configure this object for the target.
1601c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
1602c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
1603c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Specify how the target extends the result of integer and floating point
1604c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// boolean values from i1 to a wider type.  See getBooleanContents.
1605c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setBooleanContents(BooleanContent Ty) {
1606c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    BooleanContents = Ty;
1607c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    BooleanFloatContents = Ty;
1608c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1609c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1610c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Specify how the target extends the result of integer and floating point
1611c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// boolean values from i1 to a wider type.  See getBooleanContents.
1612c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setBooleanContents(BooleanContent IntTy, BooleanContent FloatTy) {
1613c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    BooleanContents = IntTy;
1614c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    BooleanFloatContents = FloatTy;
1615c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1616c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1617c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Specify how the target extends the result of a vector boolean value from a
1618c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// vector of i1 to a wider type.  See getBooleanContents.
1619c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setBooleanVectorContents(BooleanContent Ty) {
1620c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    BooleanVectorContents = Ty;
1621c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1622c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1623c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Specify the target scheduling preference.
1624c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setSchedulingPreference(Sched::Preference Pref) {
1625c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SchedPreferenceInfo = Pref;
1626c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1627c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1628c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate whether this target prefers to use _setjmp to implement
1629c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// llvm.setjmp or the version without _.  Defaults to false.
1630c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setUseUnderscoreSetJmp(bool Val) {
1631c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    UseUnderscoreSetJmp = Val;
1632c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1633c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1634c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate whether this target prefers to use _longjmp to implement
1635c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// llvm.longjmp or the version without _.  Defaults to false.
1636c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setUseUnderscoreLongJmp(bool Val) {
1637c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    UseUnderscoreLongJmp = Val;
1638c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1639c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1640c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate the minimum number of blocks to generate jump tables.
1641c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setMinimumJumpTableEntries(unsigned Val);
1642c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1643c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate the maximum number of entries in jump tables.
1644c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set to zero to generate unlimited jump tables.
1645c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setMaximumJumpTableSize(unsigned);
1646c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1647c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If set to a physical register, this specifies the register that
1648c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// llvm.savestack/llvm.restorestack should save and restore.
1649c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setStackPointerRegisterToSaveRestore(unsigned R) {
1650c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    StackPointerRegisterToSaveRestore = R;
1651c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1652c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1653c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator that the target has multiple (allocatable)
1654c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// condition registers that can be used to store the results of comparisons
1655c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for use by selects and conditional branches. With multiple condition
1656c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// registers, the code generator will not aggressively sink comparisons into
1657c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the blocks of their users.
1658c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setHasMultipleConditionRegisters(bool hasManyRegs = true) {
1659c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    HasMultipleConditionRegisters = hasManyRegs;
1660c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1661c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1662c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator that the target has BitExtract instructions.
1663c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The code generator will aggressively sink "shift"s into the blocks of
1664c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// their users if the users will generate "and" instructions which can be
1665c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// combined with "shift" to BitExtract instructions.
1666c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setHasExtractBitsInsn(bool hasExtractInsn = true) {
1667c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    HasExtractBitsInsn = hasExtractInsn;
1668c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1669c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1670c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator not to expand logic operations on comparison
1671c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// predicates into separate sequences that increase the amount of flow
1672c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// control.
1673c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setJumpIsExpensive(bool isExpensive = true);
1674c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1675c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator that this target supports floating point
1676c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// exceptions and cares about preserving floating point exception behavior.
1677c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setHasFloatingPointExceptions(bool FPExceptions = true) {
1678c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    HasFloatingPointExceptions = FPExceptions;
1679c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1680c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1681c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator which bitwidths to bypass.
1682c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void addBypassSlowDiv(unsigned int SlowBitWidth, unsigned int FastBitWidth) {
1683c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    BypassSlowDivWidths[SlowBitWidth] = FastBitWidth;
1684c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1685c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1686c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Add the specified register class as an available regclass for the
1687c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specified value type. This indicates the selector can handle values of
1688c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// that class natively.
1689c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void addRegisterClass(MVT VT, const TargetRegisterClass *RC) {
1690c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert((unsigned)VT.SimpleTy < array_lengthof(RegClassForVT));
1691c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    RegClassForVT[VT.SimpleTy] = RC;
1692c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1693c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1694c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the largest legal super-reg register class of the register class
1695c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for the specified type and its associated "cost".
1696c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual std::pair<const TargetRegisterClass *, uint8_t>
1697c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT) const;
1698c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1699c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Once all of the register classes are added, this allows us to compute
1700c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// derived properties we expose.
1701c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void computeRegisterProperties(const TargetRegisterInfo *TRI);
1702c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1703c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate that the specified operation does not work with the specified
1704c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type and indicate what to do about it. Note that VT may refer to either
1705c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the type of a result or that of an operand of Op.
1706c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setOperationAction(unsigned Op, MVT VT,
1707c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          LegalizeAction Action) {
1708c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(Op < array_lengthof(OpActions[0]) && "Table isn't big enough!");
1709c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    OpActions[(unsigned)VT.SimpleTy][Op] = Action;
1710c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1711c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1712c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate that the specified load with extension does not work with the
1713c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specified type and indicate what to do about it.
1714c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT,
1715c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                        LegalizeAction Action) {
1716c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(ExtType < ISD::LAST_LOADEXT_TYPE && ValVT.isValid() &&
1717c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           MemVT.isValid() && "Table isn't big enough!");
1718c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert((unsigned)Action < 0x10 && "too many bits for bitfield array");
1719c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned Shift = 4 * ExtType;
1720c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LoadExtActions[ValVT.SimpleTy][MemVT.SimpleTy] &= ~((uint16_t)0xF << Shift);
1721c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LoadExtActions[ValVT.SimpleTy][MemVT.SimpleTy] |= (uint16_t)Action << Shift;
1722c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1723c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1724c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate that the specified truncating store does not work with the
1725c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specified type and indicate what to do about it.
1726c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setTruncStoreAction(MVT ValVT, MVT MemVT,
1727c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                           LegalizeAction Action) {
1728c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(ValVT.isValid() && MemVT.isValid() && "Table isn't big enough!");
1729c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TruncStoreActions[(unsigned)ValVT.SimpleTy][MemVT.SimpleTy] = Action;
1730c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1731c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1732c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate that the specified indexed load does or does not work with the
1733c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specified type and indicate what to do abort it.
1734c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1735c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// NOTE: All indexed mode loads are initialized to Expand in
1736c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// TargetLowering.cpp
1737c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setIndexedLoadAction(unsigned IdxMode, MVT VT,
1738c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            LegalizeAction Action) {
1739c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(VT.isValid() && IdxMode < ISD::LAST_INDEXED_MODE &&
1740c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           (unsigned)Action < 0xf && "Table isn't big enough!");
1741c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Load action are kept in the upper half.
1742c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    IndexedModeActions[(unsigned)VT.SimpleTy][IdxMode] &= ~0xf0;
1743c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    IndexedModeActions[(unsigned)VT.SimpleTy][IdxMode] |= ((uint8_t)Action) <<4;
1744c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1745c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1746c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate that the specified indexed store does or does not work with the
1747c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specified type and indicate what to do about it.
1748c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1749c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// NOTE: All indexed mode stores are initialized to Expand in
1750c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// TargetLowering.cpp
1751c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setIndexedStoreAction(unsigned IdxMode, MVT VT,
1752c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                             LegalizeAction Action) {
1753c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(VT.isValid() && IdxMode < ISD::LAST_INDEXED_MODE &&
1754c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           (unsigned)Action < 0xf && "Table isn't big enough!");
1755c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Store action are kept in the lower half.
1756c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    IndexedModeActions[(unsigned)VT.SimpleTy][IdxMode] &= ~0x0f;
1757c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    IndexedModeActions[(unsigned)VT.SimpleTy][IdxMode] |= ((uint8_t)Action);
1758c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1759c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1760c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate that the specified condition code is or isn't supported on the
1761c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target and indicate what to do about it.
1762c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setCondCodeAction(ISD::CondCode CC, MVT VT,
1763c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                         LegalizeAction Action) {
1764c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(VT.isValid() && (unsigned)CC < array_lengthof(CondCodeActions) &&
1765c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "Table isn't big enough!");
1766c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert((unsigned)Action < 0x10 && "too many bits for bitfield array");
1767c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The lower 3 bits of the SimpleTy index into Nth 4bit set from the 32-bit
1768c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// value and the upper 29 bits index into the second dimension of the array
1769c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// to select what 32-bit value to use.
1770c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    uint32_t Shift = 4 * (VT.SimpleTy & 0x7);
1771c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CondCodeActions[CC][VT.SimpleTy >> 3] &= ~((uint32_t)0xF << Shift);
1772c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CondCodeActions[CC][VT.SimpleTy >> 3] |= (uint32_t)Action << Shift;
1773c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1774c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1775c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If Opc/OrigVT is specified as being promoted, the promotion code defaults
1776c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to trying a larger integer/fp until it can find one that works. If that
1777c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// default is insufficient, this method can be used by the target to override
1778c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the default.
1779c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void AddPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT) {
1780c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    PromoteToType[std::make_pair(Opc, OrigVT.SimpleTy)] = DestVT.SimpleTy;
1781c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1782c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1783c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Convenience method to set an operation to Promote and specify the type
1784c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// in a single call.
1785c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setOperationPromotedToType(unsigned Opc, MVT OrigVT, MVT DestVT) {
1786c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    setOperationAction(Opc, OrigVT, Promote);
1787c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    AddPromotedToType(Opc, OrigVT, DestVT);
1788c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1789c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1790c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets should invoke this method for each target independent node that
1791c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// they want to provide a custom DAG combiner for by implementing the
1792c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// PerformDAGCombine virtual method.
1793c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setTargetDAGCombine(ISD::NodeType NT) {
1794c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(unsigned(NT >> 3) < array_lengthof(TargetDAGCombineArray));
1795c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TargetDAGCombineArray[NT >> 3] |= 1 << (NT&7);
1796c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1797c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1798c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the target's required jmp_buf buffer size (in bytes); default is 200
1799c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setJumpBufSize(unsigned Size) {
1800c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    JumpBufSize = Size;
1801c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1802c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1803c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the target's required jmp_buf buffer alignment (in bytes); default is
1804c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// 0
1805c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setJumpBufAlignment(unsigned Align) {
1806c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    JumpBufAlignment = Align;
1807c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1808c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1809c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the target's minimum function alignment (in log2(bytes))
1810c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setMinFunctionAlignment(unsigned Align) {
1811c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MinFunctionAlignment = Align;
1812c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1813c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1814c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the target's preferred function alignment.  This should be set if
1815c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// there is a performance benefit to higher-than-minimum alignment (in
1816c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// log2(bytes))
1817c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setPrefFunctionAlignment(unsigned Align) {
1818c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    PrefFunctionAlignment = Align;
1819c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1820c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1821c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the target's preferred loop alignment. Default alignment is zero, it
1822c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// means the target does not care about loop alignment.  The alignment is
1823c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specified in log2(bytes). The target may also override
1824c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// getPrefLoopAlignment to provide per-loop values.
1825c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setPrefLoopAlignment(unsigned Align) {
1826c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    PrefLoopAlignment = Align;
1827c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1828c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1829c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the minimum stack alignment of an argument (in log2(bytes)).
1830c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setMinStackArgumentAlignment(unsigned Align) {
1831c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MinStackArgumentAlignment = Align;
1832c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1833c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1834c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the maximum atomic operation size supported by the
1835c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// backend. Atomic operations greater than this size (as well as
1836c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ones that are not naturally aligned), will be expanded by
1837c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// AtomicExpandPass into an __atomic_* library call.
1838c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setMaxAtomicSizeInBitsSupported(unsigned SizeInBits) {
1839c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MaxAtomicSizeInBitsSupported = SizeInBits;
1840c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1841c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1842c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Sets the minimum cmpxchg or ll/sc size supported by the backend.
1843c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setMinCmpXchgSizeInBits(unsigned SizeInBits) {
1844c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MinCmpXchgSizeInBits = SizeInBits;
1845c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1846c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1847c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
1848c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
1849c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Addressing mode description hooks (used by LSR etc).
1850c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
1851c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1852c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// CodeGenPrepare sinks address calculations into the same BB as Load/Store
1853c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// instructions reading the address. This allows as much computation as
1854c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// possible to be done in the address mode for that operand. This hook lets
1855c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// targets also pass back when this should be done on intrinsics which
1856c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// load/store.
1857c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool getAddrModeArguments(IntrinsicInst * /*I*/,
1858c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    SmallVectorImpl<Value*> &/*Ops*/,
1859c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    Type *&/*AccessTy*/) const {
1860c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1861c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1862c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1863c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This represents an addressing mode of:
1864c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///    BaseGV + BaseOffs + BaseReg + Scale*ScaleReg
1865c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If BaseGV is null,  there is no BaseGV.
1866c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If BaseOffs is zero, there is no base offset.
1867c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If HasBaseReg is false, there is no base register.
1868c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If Scale is zero, there is no ScaleReg.  Scale of 1 indicates a reg with
1869c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// no scale.
1870c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  struct AddrMode {
1871c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    GlobalValue *BaseGV = nullptr;
1872c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    int64_t      BaseOffs = 0;
1873c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool         HasBaseReg = false;
1874c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    int64_t      Scale = 0;
1875c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    AddrMode() = default;
1876c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
1877c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1878c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the addressing mode represented by AM is legal for this
1879c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target, for a load/store of the specified type.
1880c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1881c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The type may be VoidTy, in which case only return true if the addressing
1882c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// mode is legal for a load/store of any legal type.  TODO: Handle
1883c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// pre/postinc as well.
1884c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1885c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the address space cannot be determined, it will be -1.
1886c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1887c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// TODO: Remove default argument
1888c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
1889c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     Type *Ty, unsigned AddrSpace,
1890c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     Instruction *I = nullptr) const;
1891c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1892c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return the cost of the scaling factor used in the addressing mode
1893c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// represented by AM for this target, for a load/store of the specified type.
1894c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
1895c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the AM is supported, the return value must be >= 0.
1896c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the AM is not supported, it returns a negative value.
1897c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// TODO: Handle pre/postinc as well.
1898c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// TODO: Remove default argument
1899c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual int getScalingFactorCost(const DataLayout &DL, const AddrMode &AM,
1900c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                   Type *Ty, unsigned AS = 0) const {
1901c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Default: assume that any scaling factor used in a legal AM is free.
1902c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (isLegalAddressingMode(DL, AM, Ty, AS))
1903c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return 0;
1904c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return -1;
1905c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1906c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1907c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified immediate is legal icmp immediate, that is
1908c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the target has icmp instructions which can compare a register against the
1909c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// immediate without having to materialize the immediate into a register.
1910c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isLegalICmpImmediate(int64_t) const {
1911c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
1912c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1913c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1914c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the specified immediate is legal add immediate, that is the
1915c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target has add instructions which can add a register with the immediate
1916c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// without having to materialize the immediate into a register.
1917c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isLegalAddImmediate(int64_t) const {
1918c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
1919c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1920c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1921c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if it's significantly cheaper to shift a vector by a uniform
1922c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// scalar than by an amount which will vary across each lane. On x86, for
1923c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// example, there is a "psllw" instruction for the former case, but no simple
1924c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// instruction for a general "a << b" operation on vectors.
1925c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isVectorShiftByScalarCheap(Type *Ty) const {
1926c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1927c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1928c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1929c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true if the opcode is a commutative binary operation.
1930c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isCommutativeBinOp(unsigned Opcode) const {
1931c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // FIXME: This should get its info from the td file.
1932c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    switch (Opcode) {
1933c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::ADD:
1934c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::SMIN:
1935c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::SMAX:
1936c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::UMIN:
1937c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::UMAX:
1938c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::MUL:
1939c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::MULHU:
1940c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::MULHS:
1941c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::SMUL_LOHI:
1942c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::UMUL_LOHI:
1943c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::FADD:
1944c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::FMUL:
1945c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::AND:
1946c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::OR:
1947c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::XOR:
1948c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::SADDO:
1949c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::UADDO:
1950c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::ADDC:
1951c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::ADDE:
1952c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::FMINNUM:
1953c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::FMAXNUM:
1954c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::FMINNAN:
1955c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case ISD::FMAXNAN:
1956c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return true;
1957c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    default: return false;
1958c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
1959c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1960c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1961c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if it's free to truncate a value of type FromTy to type
1962c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ToTy. e.g. On x86 it's free to truncate a i32 value in register EAX to i16
1963c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// by referencing its sub-register AX.
1964c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets must return false when FromTy <= ToTy.
1965c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const {
1966c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1967c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1968c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1969c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if a truncation from FromTy to ToTy is permitted when deciding
1970c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// whether a call is in tail position. Typically this means that both results
1971c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// would be assigned to the same register or stack slot, but it could mean
1972c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the target performs adequate checks of its own before proceeding with the
1973c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// tail call.  Targets must return false when FromTy <= ToTy.
1974c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool allowTruncateForTailCall(Type *FromTy, Type *ToTy) const {
1975c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1976c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1977c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1978c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isTruncateFree(EVT FromVT, EVT ToVT) const {
1979c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
1980c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
1981c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1982c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isProfitableToHoist(Instruction *I) const { return true; }
1983c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
1984c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the extension represented by \p I is free.
1985c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Unlikely the is[Z|FP]ExtFree family which is based on types,
1986c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// this method can use the context provided by \p I to decide
1987c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// whether or not \p I is free.
1988c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method extends the behavior of the is[Z|FP]ExtFree family.
1989c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// In other words, if is[Z|FP]Free returns true, then this method
1990c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// returns true as well. The converse is not true.
1991c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The target can perform the adequate checks by overriding isExtFreeImpl.
1992c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \pre \p I must be a sign, zero, or fp extension.
1993c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isExtFree(const Instruction *I) const {
1994c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    switch (I->getOpcode()) {
1995c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case Instruction::FPExt:
1996c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      if (isFPExtFree(EVT::getEVT(I->getType()),
1997c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                      EVT::getEVT(I->getOperand(0)->getType())))
1998c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        return true;
1999c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      break;
2000c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case Instruction::ZExt:
2001c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      if (isZExtFree(I->getOperand(0)->getType(), I->getType()))
2002c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        return true;
2003c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      break;
2004c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    case Instruction::SExt:
2005c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      break;
2006c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    default:
2007c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      llvm_unreachable("Instruction is not an extension");
2008c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2009c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isExtFreeImpl(I);
2010c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2011c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2012c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if \p Load and \p Ext can form an ExtLoad.
2013c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For example, in AArch64
2014c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   %L = load i8, i8* %ptr
2015c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   %E = zext i8 %L to i32
2016c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// can be lowered into one load instruction
2017c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   ldrb w0, [x0]
2018c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isExtLoad(const LoadInst *Load, const Instruction *Ext,
2019c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                 const DataLayout &DL) const {
2020c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    EVT VT = getValueType(DL, Ext->getType());
2021c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    EVT LoadVT = getValueType(DL, Load->getType());
2022c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2023c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // If the load has other users and the truncate is not free, the ext
2024c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // probably isn't free.
2025c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (!Load->hasOneUse() && (isTypeLegal(LoadVT) || !isTypeLegal(VT)) &&
2026c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        !isTruncateFree(Ext->getType(), Load->getType()))
2027c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return false;
2028c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2029c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Check whether the target supports casts folded into loads.
2030c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned LType;
2031c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (isa<ZExtInst>(Ext))
2032c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      LType = ISD::ZEXTLOAD;
2033c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    else {
2034c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      assert(isa<SExtInst>(Ext) && "Unexpected ext type!");
2035c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      LType = ISD::SEXTLOAD;
2036c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2037c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2038c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isLoadExtLegal(LType, VT, LoadVT);
2039c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2040c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2041c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if any actual instruction that defines a value of type FromTy
2042c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// implicitly zero-extends the value to ToTy in the result register.
2043c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2044c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The function should return true when it is likely that the truncate can
2045c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// be freely folded with an instruction defining a value of FromTy. If
2046c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the defining instruction is unknown (because you're looking at a
2047c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// function argument, PHI, etc.) then the target may require an
2048c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// explicit truncate, which is not necessarily free, but this function
2049c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// does not deal with those cases.
2050c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets must return false when FromTy >= ToTy.
2051c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isZExtFree(Type *FromTy, Type *ToTy) const {
2052c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2053c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2054c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2055c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isZExtFree(EVT FromTy, EVT ToTy) const {
2056c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2057c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2058c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2059c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target supplies and combines to a paired load
2060c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// two loaded values of type LoadedType next to each other in memory.
2061c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// RequiredAlignment gives the minimal alignment constraints that must be met
2062c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to be able to select this paired load.
2063c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2064c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This information is *not* used to generate actual paired loads, but it is
2065c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// used to generate a sequence of loads that is easier to combine into a
2066c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// paired load.
2067c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For instance, something like this:
2068c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// a = load i64* addr
2069c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// b = trunc i64 a to i32
2070c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// c = lshr i64 a, 32
2071c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// d = trunc i64 c to i32
2072c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// will be optimized into:
2073c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// b = load i32* addr1
2074c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// d = load i32* addr2
2075c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Where addr1 = addr2 +/- sizeof(i32).
2076c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2077c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// In other words, unless the target performs a post-isel load combining,
2078c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// this information should not be provided because it will generate more
2079c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// loads.
2080c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool hasPairedLoad(EVT /*LoadedType*/,
2081c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                             unsigned & /*RequiredAlignment*/) const {
2082c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2083c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2084c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2085c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Get the maximum supported factor for interleaved memory accesses.
2086c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Default to be the minimum interleave factor: 2.
2087c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getMaxSupportedInterleaveFactor() const { return 2; }
2088c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2089c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Lower an interleaved load to target specific intrinsics. Return
2090c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// true on success.
2091c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2092c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p LI is the vector load instruction.
2093c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p Shuffles is the shufflevector list to DE-interleave the loaded vector.
2094c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p Indices is the corresponding indices for each shufflevector.
2095c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p Factor is the interleave factor.
2096c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool lowerInterleavedLoad(LoadInst *LI,
2097c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    ArrayRef<ShuffleVectorInst *> Shuffles,
2098c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    ArrayRef<unsigned> Indices,
2099c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    unsigned Factor) const {
2100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Lower an interleaved store to target specific intrinsics. Return
2104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// true on success.
2105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p SI is the vector store instruction.
2107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p SVI is the shufflevector to RE-interleave the stored vector.
2108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p Factor is the interleave factor.
2109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool lowerInterleavedStore(StoreInst *SI, ShuffleVectorInst *SVI,
2110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     unsigned Factor) const {
2111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if zero-extending the specific node Val to type VT2 is free
2115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (either because it's implicitly zero-extended such as ARM ldrb / ldrh or
2116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// because it's folded such as X86 zero-extending loads).
2117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isZExtFree(SDValue Val, EVT VT2) const {
2118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isZExtFree(Val.getValueType(), VT2);
2119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if an fpext operation is free (for instance, because
2122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// single-precision floating-point numbers are implicitly extended to
2123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// double-precision).
2124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isFPExtFree(EVT DestVT, EVT SrcVT) const {
2125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(SrcVT.isFloatingPoint() && DestVT.isFloatingPoint() &&
2126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "invalid fpext types");
2127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if an fpext operation input to an \p Opcode operation is free
2131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (for instance, because half-precision floating-point numbers are
2132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// implicitly extended to float-precision) for an FMA instruction.
2133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isFPExtFoldable(unsigned Opcode, EVT DestVT, EVT SrcVT) const {
2134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(DestVT.isFloatingPoint() && SrcVT.isFloatingPoint() &&
2135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           "invalid fpext types");
2136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isFPExtFree(DestVT, SrcVT);
2137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if folding a vector load into ExtVal (a sign, zero, or any
2140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// extend node) is profitable.
2141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isVectorLoadExtDesirable(SDValue ExtVal) const { return false; }
2142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if an fneg operation is free to the point where it is never
2144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// worthwhile to replace it with a bitwise operation.
2145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isFNegFree(EVT VT) const {
2146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(VT.isFloatingPoint());
2147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if an fabs operation is free to the point where it is never
2151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// worthwhile to replace it with a bitwise operation.
2152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isFAbsFree(EVT VT) const {
2153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    assert(VT.isFloatingPoint());
2154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if an FMA operation is faster than a pair of fmul and fadd
2158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// instructions. fmuladd intrinsics will be expanded to FMAs when this method
2159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// returns true, otherwise fmuladd is expanded to fmul + fadd.
2160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// NOTE: This may be called before legalization on types for which FMAs are
2162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// not legal, but should return true if those types will eventually legalize
2163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to types that support FMAs. After legalization, it will only be called on
2164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// types that support FMAs (via Legal or Custom actions)
2165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isFMAFasterThanFMulAndFAdd(EVT) const {
2166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if it's profitable to narrow operations of type VT1 to
2170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// VT2. e.g. on x86, it's profitable to narrow from i32 to i8 but not from
2171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// i32 to i16.
2172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isNarrowingProfitable(EVT /*VT1*/, EVT /*VT2*/) const {
2173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Return true if it is beneficial to convert a load of a constant to
2177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// just the constant itself.
2178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// On some targets it might be more efficient to use a combination of
2179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// arithmetic instructions to materialize the constant instead of loading it
2180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// from a constant pool.
2181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
2182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                 Type *Ty) const {
2183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if EXTRACT_SUBVECTOR is cheap for extracting this result type
2187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// from this source type with this index. This is needed because
2188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// EXTRACT_SUBVECTOR usually has custom lowering that depends on the index of
2189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the first element, and only the target knows which lowering is cheap.
2190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
2191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       unsigned Index) const {
2192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Return true if it is profitable to use a scalar input to a BUILD_VECTOR
2196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // even if the vector itself has multiple uses.
2197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool aggressivelyPreferBuildVectorSources(EVT VecVT) const {
2198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
2202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Runtime Library hooks
2203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
2204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Rename the default libcall routine name for the specified libcall.
2206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setLibcallName(RTLIB::Libcall Call, const char *Name) {
2207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LibcallRoutineNames[Call] = Name;
2208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Get the libcall routine name for the specified libcall.
2211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const char *getLibcallName(RTLIB::Libcall Call) const {
2212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return LibcallRoutineNames[Call];
2213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Override the default CondCode to be used to test the result of the
2216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// comparison libcall against zero.
2217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setCmpLibcallCC(RTLIB::Libcall Call, ISD::CondCode CC) {
2218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CmpLibcallCCs[Call] = CC;
2219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Get the CondCode that's to be used to test the result of the comparison
2222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// libcall against zero.
2223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ISD::CondCode getCmpLibcallCC(RTLIB::Libcall Call) const {
2224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return CmpLibcallCCs[Call];
2225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Set the CallingConv that should be used for the specified libcall.
2228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setLibcallCallingConv(RTLIB::Libcall Call, CallingConv::ID CC) {
2229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LibcallCallingConvs[Call] = CC;
2230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Get the CallingConv that should be used for the specified libcall.
2233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
2234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return LibcallCallingConvs[Call];
2235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Execute target specific actions to finalize target lowering.
2238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This is used to set extra flags in MachineFrameInformation and freezing
2239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the set of reserved registers.
2240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The default implementation just freezes the set of reserved registers.
2241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void finalizeLowering(MachineFunction &MF) const;
2242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
2244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const TargetMachine &TM;
2245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator that the target has multiple (allocatable)
2247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// condition registers that can be used to store the results of comparisons
2248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for use by selects and conditional branches. With multiple condition
2249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// registers, the code generator will not aggressively sink comparisons into
2250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the blocks of their users.
2251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool HasMultipleConditionRegisters;
2252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator that the target has BitExtract instructions.
2254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The code generator will aggressively sink "shift"s into the blocks of
2255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// their users if the users will generate "and" instructions which can be
2256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// combined with "shift" to BitExtract instructions.
2257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool HasExtractBitsInsn;
2258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator to bypass slow divide or remainder
2260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// instructions. For example, BypassSlowDivWidths[32,8] tells the code
2261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// generator to bypass 32-bit integer div/rem with an 8-bit unsigned integer
2262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// div/rem when the operands are positive and less than 256.
2263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  DenseMap <unsigned int, unsigned int> BypassSlowDivWidths;
2264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator that it shouldn't generate extra flow control
2266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// instructions and should attempt to combine flow control instructions via
2267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// predication.
2268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool JumpIsExpensive;
2269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Whether the target supports or cares about preserving floating point
2271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// exception behavior.
2272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool HasFloatingPointExceptions;
2273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This target prefers to use _setjmp to implement llvm.setjmp.
2275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Defaults to false.
2277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool UseUnderscoreSetJmp;
2278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This target prefers to use _longjmp to implement llvm.longjmp.
2280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Defaults to false.
2282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool UseUnderscoreLongJmp;
2283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Information about the contents of the high-bits in boolean values held in
2285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// a type wider than i1. See getBooleanContents.
2286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  BooleanContent BooleanContents;
2287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Information about the contents of the high-bits in boolean values held in
2289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// a type wider than i1. See getBooleanContents.
2290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  BooleanContent BooleanFloatContents;
2291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Information about the contents of the high-bits in boolean vector values
2293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// when the element type is wider than i1. See getBooleanContents.
2294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  BooleanContent BooleanVectorContents;
2295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The target scheduling preference: shortest possible total cycles or lowest
2297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register usage.
2298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Sched::Preference SchedPreferenceInfo;
2299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The size, in bytes, of the target's jmp_buf buffers
2301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned JumpBufSize;
2302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The alignment, in bytes, of the target's jmp_buf buffers
2304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned JumpBufAlignment;
2305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The minimum alignment that any argument on the stack needs to have.
2307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MinStackArgumentAlignment;
2308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The minimum function alignment (used when optimizing for size, and to
2310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// prevent explicitly provided alignment from leading to incorrect code).
2311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MinFunctionAlignment;
2312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The preferred function alignment (used when alignment unspecified and
2314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// optimizing for speed).
2315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned PrefFunctionAlignment;
2316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The preferred loop alignment.
2318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned PrefLoopAlignment;
2319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Size in bits of the maximum atomics size the backend supports.
2321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Accesses larger than this will be expanded by AtomicExpandPass.
2322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxAtomicSizeInBitsSupported;
2323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Size in bits of the minimum cmpxchg or ll/sc operation the
2325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// backend supports.
2326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MinCmpXchgSizeInBits;
2327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If set to a physical register, this specifies the register that
2329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// llvm.savestack/llvm.restorestack should save and restore.
2330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned StackPointerRegisterToSaveRestore;
2331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This indicates the default register class to use for each ValueType the
2333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target supports natively.
2334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const TargetRegisterClass *RegClassForVT[MVT::LAST_VALUETYPE];
2335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned char NumRegistersForVT[MVT::LAST_VALUETYPE];
2336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT RegisterTypeForVT[MVT::LAST_VALUETYPE];
2337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This indicates the "representative" register class to use for each
2339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ValueType the target supports natively. This information is used by the
2340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// scheduler to track register pressure. By default, the representative
2341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register class is the largest legal super-reg register class of the
2342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register class of the specified type. e.g. On x86, i8, i16, and i32's
2343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// representative class would be GR32.
2344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const TargetRegisterClass *RepRegClassForVT[MVT::LAST_VALUETYPE];
2345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This indicates the "cost" of the "representative" register class for each
2347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ValueType. The cost is used by the scheduler to approximate register
2348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// pressure.
2349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint8_t RepRegClassCostForVT[MVT::LAST_VALUETYPE];
2350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For any value types we are promoting or expanding, this contains the value
2352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type that we are changing to.  For Expanded types, this contains one step
2353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// of the expand (e.g. i64 -> i32), even if there are multiple steps required
2354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (e.g. i64 -> i16).  For types natively supported by the system, this holds
2355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the same type (e.g. i32 -> i32).
2356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MVT TransformToType[MVT::LAST_VALUETYPE];
2357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For each operation and each value type, keep a LegalizeAction that
2359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// indicates how instruction selection should deal with the operation.  Most
2360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operations are Legal (aka, supported natively by the target), but
2361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operations that are not should be described.  Note that operations on
2362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// non-legal value types are not described here.
2363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction OpActions[MVT::LAST_VALUETYPE][ISD::BUILTIN_OP_END];
2364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For each load extension type and each value type, keep a LegalizeAction
2366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// that indicates how instruction selection should deal with a load of a
2367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specific value type and extension type. Uses 4-bits to store the action
2368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for each of the 4 load ext types.
2369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint16_t LoadExtActions[MVT::LAST_VALUETYPE][MVT::LAST_VALUETYPE];
2370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For each value type pair keep a LegalizeAction that indicates whether a
2372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// truncating store of a specific value type and truncating type is legal.
2373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeAction TruncStoreActions[MVT::LAST_VALUETYPE][MVT::LAST_VALUETYPE];
2374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For each indexed mode and each value type, keep a pair of LegalizeAction
2376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// that indicates how instruction selection should deal with the load /
2377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store.
2378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The first dimension is the value_type for the reference. The second
2380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// dimension represents the various modes for load store.
2381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint8_t IndexedModeActions[MVT::LAST_VALUETYPE][ISD::LAST_INDEXED_MODE];
2382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For each condition code (ISD::CondCode) keep a LegalizeAction that
2384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// indicates how instruction selection should deal with the condition code.
2385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Because each CC action takes up 4 bits, we need to have the array size be
2387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// large enough to fit all of the value types. This can be done by rounding
2388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// up the MVT::LAST_VALUETYPE value to the next multiple of 8.
2389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  uint32_t CondCodeActions[ISD::SETCC_INVALID][(MVT::LAST_VALUETYPE + 7) / 8];
2390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
2392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ValueTypeActionImpl ValueTypeActions;
2393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
2395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LegalizeKind getTypeConversion(LLVMContext &Context, EVT VT) const;
2396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets can specify ISD nodes that they would like PerformDAGCombine
2398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// callbacks for by calling setTargetDAGCombine(), which sets a bit in this
2399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// array.
2400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned char
2401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  TargetDAGCombineArray[(ISD::BUILTIN_OP_END+CHAR_BIT-1)/CHAR_BIT];
2402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For operations that must be promoted to a specific type, this holds the
2404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// destination type.  This map should be sparse, so don't hold it as an
2405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// array.
2406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets add entries to this map with AddPromotedToType(..), clients access
2408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// this with getTypeToPromoteTo(..).
2409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::map<std::pair<unsigned, MVT::SimpleValueType>, MVT::SimpleValueType>
2410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    PromoteToType;
2411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Stores the name each libcall.
2413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL];
2414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The ISD::CondCode that should be used to test the result of each of the
2416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// comparison libcall against zero.
2417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ISD::CondCode CmpLibcallCCs[RTLIB::UNKNOWN_LIBCALL];
2418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Stores the CallingConv that should be used for each libcall.
2420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL];
2421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
2423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the extension represented by \p I is free.
2424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \pre \p I is a sign, zero, or fp extension and
2425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///      is[Z|FP]ExtFree of the related types is not true.
2426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isExtFreeImpl(const Instruction *I) const { return false; }
2427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Depth that GatherAllAliases should should continue looking for chain
2429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// dependencies when trying to find a more preferable chain. As an
2430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// approximation, this should be more than the number of consecutive stores
2431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// expected to be merged.
2432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned GatherAllAliasesMaxDepth;
2433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Specify maximum number of store instructions per memset call.
2435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// When lowering \@llvm.memset this field specifies the maximum number of
2437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store operations that may be substituted for the call to memset. Targets
2438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// must set this value based on the cost threshold for that target. Targets
2439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// should assume that the memset will be done using as many of the largest
2440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store operations first, followed by smaller ones, if necessary, per
2441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// alignment restrictions. For example, storing 9 bytes on a 32-bit machine
2442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// with 16-bit alignment would result in four 2-byte stores and one 1-byte
2443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store.  This only applies to setting a constant array of a constant size.
2444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxStoresPerMemset;
2445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Maximum number of stores operations that may be substituted for the call
2447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to memset, used for functions with OptSize attribute.
2448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxStoresPerMemsetOptSize;
2449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Specify maximum bytes of store instructions per memcpy call.
2451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// When lowering \@llvm.memcpy this field specifies the maximum number of
2453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store operations that may be substituted for a call to memcpy. Targets
2454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// must set this value based on the cost threshold for that target. Targets
2455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// should assume that the memcpy will be done using as many of the largest
2456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store operations first, followed by smaller ones, if necessary, per
2457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// alignment restrictions. For example, storing 7 bytes on a 32-bit machine
2458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// with 32-bit alignment would result in one 4-byte store, a one 2-byte store
2459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// and one 1-byte store. This only applies to copying a constant array of
2460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// constant size.
2461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxStoresPerMemcpy;
2462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Maximum number of store operations that may be substituted for a call to
2464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// memcpy, used for functions with OptSize attribute.
2465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxStoresPerMemcpyOptSize;
2466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxLoadsPerMemcmp;
2467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxLoadsPerMemcmpOptSize;
2468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \brief Specify maximum bytes of store instructions per memmove call.
2470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// When lowering \@llvm.memmove this field specifies the maximum number of
2472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store instructions that may be substituted for a call to memmove. Targets
2473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// must set this value based on the cost threshold for that target. Targets
2474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// should assume that the memmove will be done using as many of the largest
2475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// store operations first, followed by smaller ones, if necessary, per
2476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// alignment restrictions. For example, moving 9 bytes on a 32-bit machine
2477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// with 8-bit alignment would result in nine 1-byte stores.  This only
2478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// applies to copying a constant array of constant size.
2479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxStoresPerMemmove;
2480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Maximum number of store instructions that may be substituted for a call to
2482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// memmove, used for functions with OptSize attribute.
2483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  unsigned MaxStoresPerMemmoveOptSize;
2484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Tells the code generator that select is more expensive than a branch if
2486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the branch is usually predicted right.
2487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool PredictableSelectIsExpensive;
2488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \see enableExtLdPromotion.
2490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool EnableExtLdPromotion;
2491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the value types that can be represented by the specified
2493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// register class are all legal.
2494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isLegalRC(const TargetRegisterInfo &TRI,
2495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                 const TargetRegisterClass &RC) const;
2496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Replace/modify any TargetFrameIndex operands with a targte-dependent
2498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// sequence of memory operands that is recognized by PrologEpilogInserter.
2499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MachineBasicBlock *emitPatchPoint(MachineInstr &MI,
2500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                    MachineBasicBlock *MBB) const;
2501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
2502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This class defines information used to lower LLVM code to legal SelectionDAG
2504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// operators that the target instruction selector can accept natively.
2505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot///
2506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// This class also defines callbacks that targets must implement to lower
2507c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// target-specific constructs to SelectionDAG operators.
2508c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass TargetLowering : public TargetLoweringBase {
2509c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
2510c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  struct DAGCombinerInfo;
2511c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2512c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  TargetLowering(const TargetLowering &) = delete;
2513c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  TargetLowering &operator=(const TargetLowering &) = delete;
2514c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2515c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// NOTE: The TargetMachine owns TLOF.
2516c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  explicit TargetLowering(const TargetMachine &TM);
2517c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2518c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isPositionIndependent() const;
2519c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2520c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true by value, base pointer and offset pointer and addressing mode
2521c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// by reference if the node's address can be legally represented as
2522c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// pre-indexed load / store address.
2523c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool getPreIndexedAddressParts(SDNode * /*N*/, SDValue &/*Base*/,
2524c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                         SDValue &/*Offset*/,
2525c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                         ISD::MemIndexedMode &/*AM*/,
2526c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                         SelectionDAG &/*DAG*/) const {
2527c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2528c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2529c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2530c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true by value, base pointer and offset pointer and addressing mode
2531c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// by reference if this node can be combined with a load / store to form a
2532c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// post-indexed load / store.
2533c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool getPostIndexedAddressParts(SDNode * /*N*/, SDNode * /*Op*/,
2534c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          SDValue &/*Base*/,
2535c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          SDValue &/*Offset*/,
2536c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          ISD::MemIndexedMode &/*AM*/,
2537c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          SelectionDAG &/*DAG*/) const {
2538c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2539c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2540c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2541c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the entry encoding for a jump table in the current function.  The
2542c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// returned value is a member of the MachineJumpTableInfo::JTEntryKind enum.
2543c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getJumpTableEncoding() const;
2544c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2545c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const MCExpr *
2546c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  LowerCustomJumpTableEntry(const MachineJumpTableInfo * /*MJTI*/,
2547c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            const MachineBasicBlock * /*MBB*/, unsigned /*uid*/,
2548c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            MCContext &/*Ctx*/) const {
2549c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Need to implement this hook if target has custom JTIs");
2550c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2551c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2552c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns relocation base for the given PIC jumptable.
2553c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue getPICJumpTableRelocBase(SDValue Table,
2554c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                           SelectionDAG &DAG) const;
2555c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2556c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This returns the relocation base for the given PIC jumptable, the same as
2557c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// getPICJumpTableRelocBase, but as an MCExpr.
2558c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const MCExpr *
2559c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getPICJumpTableRelocBaseExpr(const MachineFunction *MF,
2560c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               unsigned JTI, MCContext &Ctx) const;
2561c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2562c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if folding a constant offset with the given GlobalAddress is
2563c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// legal.  It is frequently not legal in PIC relocation models.
2564c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
2565c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2566c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isInTailCallPosition(SelectionDAG &DAG, SDNode *Node,
2567c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            SDValue &Chain) const;
2568c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2569c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void softenSetCCOperands(SelectionDAG &DAG, EVT VT, SDValue &NewLHS,
2570c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                           SDValue &NewRHS, ISD::CondCode &CCCode,
2571c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                           const SDLoc &DL) const;
2572c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2573c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns a pair of (return value, chain).
2574c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// It is an error to pass RTLIB::UNKNOWN_LIBCALL as \p LC.
2575c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::pair<SDValue, SDValue> makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC,
2576c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          EVT RetVT, ArrayRef<SDValue> Ops,
2577c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          bool isSigned, const SDLoc &dl,
2578c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          bool doesNotReturn = false,
2579c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          bool isReturnValueUsed = true) const;
2580c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2581c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Check whether parameters to a call that are passed in callee saved
2582c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// registers are the same as from the calling function.  This needs to be
2583c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// checked for tail call eligibility.
2584c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool parametersInCSRMatch(const MachineRegisterInfo &MRI,
2585c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      const uint32_t *CallerPreservedMask,
2586c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      const SmallVectorImpl<CCValAssign> &ArgLocs,
2587c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      const SmallVectorImpl<SDValue> &OutVals) const;
2588c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2589c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
2590c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // TargetLowering Optimization Methods
2591c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
2592c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2593c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// A convenience struct that encapsulates a DAG, and two SDValues for
2594c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// returning information from TargetLowering to its clients that want to
2595c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// combine.
2596c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  struct TargetLoweringOpt {
2597c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SelectionDAG &DAG;
2598c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool LegalTys;
2599c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool LegalOps;
2600c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue Old;
2601c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue New;
2602c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2603c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    explicit TargetLoweringOpt(SelectionDAG &InDAG,
2604c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               bool LT, bool LO) :
2605c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      DAG(InDAG), LegalTys(LT), LegalOps(LO) {}
2606c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2607c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool LegalTypes() const { return LegalTys; }
2608c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool LegalOperations() const { return LegalOps; }
2609c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2610c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool CombineTo(SDValue O, SDValue N) {
2611c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Old = O;
2612c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      New = N;
2613c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return true;
2614c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2615c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
2616c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2617c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Check to see if the specified operand of the specified instruction is a
2618c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// constant integer.  If so, check to see if there are any bits set in the
2619c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// constant that are not demanded.  If so, shrink the constant and return
2620c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// true.
2621c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool ShrinkDemandedConstant(SDValue Op, const APInt &Demanded,
2622c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              TargetLoweringOpt &TLO) const;
2623c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2624c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Target hook to do target-specific const optimization, which is called by
2625c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // ShrinkDemandedConstant. This function should return true if the target
2626c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // doesn't want ShrinkDemandedConstant to further optimize the constant.
2627c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool targetShrinkDemandedConstant(SDValue Op, const APInt &Demanded,
2628c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            TargetLoweringOpt &TLO) const {
2629c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2630c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2631c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2632c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Convert x+y to (VT)((SmallVT)x+(SmallVT)y) if the casts are free.  This
2633c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// uses isZExtFree and ZERO_EXTEND for the widening cast, but it could be
2634c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// generalized for targets with other types of implicit widening casts.
2635c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool ShrinkDemandedOp(SDValue Op, unsigned BitWidth, const APInt &Demanded,
2636c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                        TargetLoweringOpt &TLO) const;
2637c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2638c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Helper for SimplifyDemandedBits that can simplify an operation with
2639c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// multiple uses.  This function simplifies operand \p OpIdx of \p User and
2640c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// then updates \p User with the simplified version. No other uses of
2641c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p OpIdx are updated. If \p User is the only user of \p OpIdx, this
2642c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// function behaves exactly like function SimplifyDemandedBits declared
2643c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// below except that it also updates the DAG by calling
2644c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// DCI.CommitTargetLoweringOpt.
2645c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool SimplifyDemandedBits(SDNode *User, unsigned OpIdx, const APInt &Demanded,
2646c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            DAGCombinerInfo &DCI, TargetLoweringOpt &TLO) const;
2647c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2648c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Look at Op.  At this point, we know that only the DemandedMask bits of the
2649c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// result of Op are ever used downstream.  If we can use this information to
2650c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// simplify Op, create a new simplified DAG node and return true, returning
2651c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the original and new nodes in Old and New.  Otherwise, analyze the
2652c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// expression and return a mask of KnownOne and KnownZero bits for the
2653c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// expression (used to simplify the caller).  The KnownZero/One bits may only
2654c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// be accurate for those bits in the DemandedMask.
2655c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p AssumeSingleUse When this parameter is true, this function will
2656c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///    attempt to simplify \p Op even if there are multiple uses.
2657c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///    Callers are responsible for correctly updating the DAG based on the
2658c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///    results of this function, because simply replacing replacing TLO.Old
2659c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///    with TLO.New will be incorrect when this parameter is true and TLO.Old
2660c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///    has multiple uses.
2661c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedMask,
2662c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            KnownBits &Known,
2663c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            TargetLoweringOpt &TLO,
2664c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            unsigned Depth = 0,
2665c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            bool AssumeSingleUse = false) const;
2666c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2667c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Helper wrapper around SimplifyDemandedBits
2668c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool SimplifyDemandedBits(SDValue Op, const APInt &DemandedMask,
2669c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                            DAGCombinerInfo &DCI) const;
2670c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2671c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Determine which of the bits specified in Mask are known to be either zero
2672c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// or one and return them in the KnownZero/KnownOne bitsets. The DemandedElts
2673c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// argument allows us to only collect the known bits that are shared by the
2674c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// requested vector elements.
2675c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void computeKnownBitsForTargetNode(const SDValue Op,
2676c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                             KnownBits &Known,
2677c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                             const APInt &DemandedElts,
2678c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                             const SelectionDAG &DAG,
2679c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                             unsigned Depth = 0) const;
2680c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2681c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method can be implemented by targets that want to expose additional
2682c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// information about sign bits to the DAG Combiner. The DemandedElts
2683c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// argument allows us to only collect the minimum sign bits that are shared
2684c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// by the requested vector elements.
2685c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
2686c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                   const APInt &DemandedElts,
2687c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                   const SelectionDAG &DAG,
2688c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                   unsigned Depth = 0) const;
2689c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2690c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  struct DAGCombinerInfo {
2691c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void *DC;  // The DAG Combiner object.
2692c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CombineLevel Level;
2693c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool CalledByLegalizer;
2694c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2695c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  public:
2696c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SelectionDAG &DAG;
2697c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2698c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    DAGCombinerInfo(SelectionDAG &dag, CombineLevel level,  bool cl, void *dc)
2699c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : DC(dc), Level(level), CalledByLegalizer(cl), DAG(dag) {}
2700c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2701c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool isBeforeLegalize() const { return Level == BeforeLegalizeTypes; }
2702c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool isBeforeLegalizeOps() const { return Level < AfterLegalizeVectorOps; }
2703c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool isAfterLegalizeVectorOps() const {
2704c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return Level == AfterLegalizeDAG;
2705c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2706c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CombineLevel getDAGCombineLevel() { return Level; }
2707c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool isCalledByLegalizer() const { return CalledByLegalizer; }
2708c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2709c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void AddToWorklist(SDNode *N);
2710c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue CombineTo(SDNode *N, ArrayRef<SDValue> To, bool AddTo = true);
2711c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue CombineTo(SDNode *N, SDValue Res, bool AddTo = true);
2712c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue CombineTo(SDNode *N, SDValue Res0, SDValue Res1, bool AddTo = true);
2713c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2714c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    void CommitTargetLoweringOpt(const TargetLoweringOpt &TLO);
2715c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
2716c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2717c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return if the N is a constant or constant vector equal to the true value
2718c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// from getBooleanContents().
2719c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isConstTrueVal(const SDNode *N) const;
2720c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2721c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return if the N is a constant or constant vector equal to the false value
2722c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// from getBooleanContents().
2723c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isConstFalseVal(const SDNode *N) const;
2724c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2725c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return a constant of type VT that contains a true value that respects
2726c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// getBooleanContents()
2727c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue getConstTrueVal(SelectionDAG &DAG, EVT VT, const SDLoc &DL) const;
2728c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2729c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return if \p N is a True value when extended to \p VT.
2730c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isExtendedTrueVal(const ConstantSDNode *N, EVT VT, bool Signed) const;
2731c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2732c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Try to simplify a setcc built with the specified operands and cc. If it is
2733c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// unable to simplify it, return a null SDValue.
2734c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue SimplifySetCC(EVT VT, SDValue N0, SDValue N1, ISD::CondCode Cond,
2735c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                        bool foldBooleans, DAGCombinerInfo &DCI,
2736c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                        const SDLoc &dl) const;
2737c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2738c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // For targets which wrap address, unwrap for analysis.
2739c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue unwrapAddress(SDValue N) const { return N; }
2740c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2741c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns true (and the GlobalValue and the offset) if the node is a
2742c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// GlobalAddress + offset.
2743c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool
2744c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  isGAPlusOffset(SDNode *N, const GlobalValue* &GA, int64_t &Offset) const;
2745c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2746c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method will be invoked for all target nodes and for any
2747c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target-independent nodes that the target has registered with invoke it
2748c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for.
2749c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2750c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The semantics are as follows:
2751c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return Value:
2752c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   SDValue.Val == 0   - No change was made
2753c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   SDValue.Val == N   - N was replaced, is dead, and is already handled.
2754c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///   otherwise          - N should be replaced by the returned Operand.
2755c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2756c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// In addition, methods provided by DAGCombinerInfo may be used to perform
2757c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// more complex transformations.
2758c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
2759c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
2760c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2761c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if it is profitable to move a following shift through this
2762c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //  node, adjusting any immediate operands as necessary to preserve semantics.
2763c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //  This transformation may not be desirable if it disrupts a particularly
2764c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //  auspicious target-specific tree (e.g. bitfield extraction in AArch64).
2765c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //  By default, it returns true.
2766c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isDesirableToCommuteWithShift(const SDNode *N) const {
2767c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
2768c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2769c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2770c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Return true if it is profitable to combine a BUILD_VECTOR with a stride-pattern
2771c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // to a shuffle and a truncate.
2772c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Example of such a combine:
2773c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // v4i32 build_vector((extract_elt V, 1),
2774c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //                    (extract_elt V, 3),
2775c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //                    (extract_elt V, 5),
2776c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //                    (extract_elt V, 7))
2777c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //  -->
2778c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // v4i32 truncate (bitcast (shuffle<1,u,3,u,5,u,7,u> V, u) to v4i64)
2779c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isDesirableToCombineBuildVectorToShuffleTruncate(
2780c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      ArrayRef<int> ShuffleMask, EVT SrcVT, EVT TruncVT) const {
2781c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2782c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2783c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2784c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target has native support for the specified value type
2785c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// and it is 'desirable' to use the type for the given node type. e.g. On x86
2786c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// i16 is legal, but undesirable since i16 instruction encodings are longer
2787c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// and some i16 instructions are slow.
2788c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isTypeDesirableForOp(unsigned /*Opc*/, EVT VT) const {
2789c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // By default, assume all legal types are desirable.
2790c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return isTypeLegal(VT);
2791c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2792c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2793c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if it is profitable for dag combiner to transform a floating
2794c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// point op of specified opcode to a equivalent op of an integer
2795c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type. e.g. f32 load -> i32 load can be profitable on ARM.
2796c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isDesirableToTransformToIntegerOp(unsigned /*Opc*/,
2797c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                 EVT /*VT*/) const {
2798c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2799c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2800c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2801c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method query the target whether it is beneficial for dag combiner to
2802c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// promote the specified node. If true, it should return the desired
2803c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// promotion type by reference.
2804c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool IsDesirableToPromoteOp(SDValue /*Op*/, EVT &/*PVT*/) const {
2805c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2806c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2807c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2808c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target supports swifterror attribute. It optimizes
2809c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// loads and stores to reading and writing a specific register.
2810c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool supportSwiftError() const {
2811c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2812c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2813c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2814c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target supports that a subset of CSRs for the given
2815c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// machine function is handled explicitly via copies.
2816c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool supportSplitCSR(MachineFunction *MF) const {
2817c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
2818c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2819c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2820c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Perform necessary initialization to handle a subset of CSRs explicitly
2821c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// via copies. This function is called at the beginning of instruction
2822c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// selection.
2823c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void initializeSplitCSR(MachineBasicBlock *Entry) const {
2824c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Not Implemented");
2825c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2826c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2827c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Insert explicit copies in entry and exit blocks. We copy a subset of
2828c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// CSRs to virtual registers in the entry block, and copy them back to
2829c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// physical registers in the exit blocks. This function is called at the end
2830c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// of instruction selection.
2831c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void insertCopiesSplitCSR(
2832c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      MachineBasicBlock *Entry,
2833c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      const SmallVectorImpl<MachineBasicBlock *> &Exits) const {
2834c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Not Implemented");
2835c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2836c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2837c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
2838c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Lowering methods - These methods must be implemented by targets so that
2839c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // the SelectionDAGBuilder code knows how to lower these.
2840c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
2841c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2842c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This hook must be implemented to lower the incoming (formal) arguments,
2843c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// described by the Ins array, into the specified DAG. The implementation
2844c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// should fill in the InVals array with legal-type argument values, and
2845c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// return the resulting token chain value.
2846c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue LowerFormalArguments(
2847c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      SDValue /*Chain*/, CallingConv::ID /*CallConv*/, bool /*isVarArg*/,
2848c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      const SmallVectorImpl<ISD::InputArg> & /*Ins*/, const SDLoc & /*dl*/,
2849c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      SelectionDAG & /*DAG*/, SmallVectorImpl<SDValue> & /*InVals*/) const {
2850c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Not Implemented");
2851c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
2852c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2853c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This structure contains all information that is necessary for lowering
2854c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// calls. It is passed to TLI::LowerCallTo when the SelectionDAG builder
2855c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// needs to lower a call, and targets will see this struct in their LowerCall
2856c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// implementation.
2857c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  struct CallLoweringInfo {
2858c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue Chain;
2859c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Type *RetTy = nullptr;
2860c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool RetSExt           : 1;
2861c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool RetZExt           : 1;
2862c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsVarArg          : 1;
2863c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsInReg           : 1;
2864c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool DoesNotReturn     : 1;
2865c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsReturnValueUsed : 1;
2866c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsConvergent      : 1;
2867c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsPatchPoint      : 1;
2868c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2869c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // IsTailCall should be modified by implementations of
2870c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // TargetLowering::LowerCall that perform tail call conversions.
2871c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsTailCall = false;
2872c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2873c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Is Call lowering done post SelectionDAG type legalization.
2874c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool IsPostTypeLegalization = false;
2875c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2876c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned NumFixedArgs = -1;
2877c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallingConv::ID CallConv = CallingConv::C;
2878c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDValue Callee;
2879c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ArgListTy Args;
2880c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SelectionDAG &DAG;
2881c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SDLoc DL;
2882c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ImmutableCallSite CS;
2883c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SmallVector<ISD::OutputArg, 32> Outs;
2884c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SmallVector<SDValue, 32> OutVals;
2885c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SmallVector<ISD::InputArg, 32> Ins;
2886c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SmallVector<SDValue, 4> InVals;
2887c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2888c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo(SelectionDAG &DAG)
2889c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        : RetSExt(false), RetZExt(false), IsVarArg(false), IsInReg(false),
2890c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          DoesNotReturn(false), IsReturnValueUsed(true), IsConvergent(false),
2891c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          IsPatchPoint(false), DAG(DAG) {}
2892c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2893c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setDebugLoc(const SDLoc &dl) {
2894c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      DL = dl;
2895c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2896c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2897c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2898c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setChain(SDValue InChain) {
2899c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Chain = InChain;
2900c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2901c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2902c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2903c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // setCallee with target/module-specific attributes
2904c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setLibCallee(CallingConv::ID CC, Type *ResultType,
2905c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                   SDValue Target, ArgListTy &&ArgsList) {
2906c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      RetTy = ResultType;
2907c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Callee = Target;
2908c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CallConv = CC;
2909c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      NumFixedArgs = ArgsList.size();
2910c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Args = std::move(ArgsList);
2911c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2912c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      DAG.getTargetLoweringInfo().markLibCallAttributes(
2913c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          &(DAG.getMachineFunction()), CC, Args);
2914c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2915c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2916c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2917c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setCallee(CallingConv::ID CC, Type *ResultType,
2918c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                SDValue Target, ArgListTy &&ArgsList) {
2919c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      RetTy = ResultType;
2920c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Callee = Target;
2921c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CallConv = CC;
2922c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      NumFixedArgs = ArgsList.size();
2923c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Args = std::move(ArgsList);
2924c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2925c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2926c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2927c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setCallee(Type *ResultType, FunctionType *FTy,
2928c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                SDValue Target, ArgListTy &&ArgsList,
2929c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                ImmutableCallSite Call) {
2930c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      RetTy = ResultType;
2931c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2932c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsInReg = Call.hasRetAttr(Attribute::InReg);
2933c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      DoesNotReturn =
2934c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          Call.doesNotReturn() ||
2935c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot          (!Call.isInvoke() &&
2936c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot           isa<UnreachableInst>(Call.getInstruction()->getNextNode()));
2937c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsVarArg = FTy->isVarArg();
2938c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsReturnValueUsed = !Call.getInstruction()->use_empty();
2939c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      RetSExt = Call.hasRetAttr(Attribute::SExt);
2940c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      RetZExt = Call.hasRetAttr(Attribute::ZExt);
2941c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2942c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Callee = Target;
2943c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2944c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CallConv = Call.getCallingConv();
2945c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      NumFixedArgs = FTy->getNumParams();
2946c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      Args = std::move(ArgsList);
2947c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2948c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      CS = Call;
2949c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2950c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2951c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2952c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2953c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setInRegister(bool Value = true) {
2954c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsInReg = Value;
2955c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2956c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2957c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2958c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setNoReturn(bool Value = true) {
2959c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      DoesNotReturn = Value;
2960c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2961c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2962c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2963c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setVarArg(bool Value = true) {
2964c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsVarArg = Value;
2965c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2966c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2967c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2968c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setTailCall(bool Value = true) {
2969c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsTailCall = Value;
2970c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2971c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2972c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2973c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setDiscardResult(bool Value = true) {
2974c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsReturnValueUsed = !Value;
2975c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2976c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2977c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2978c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setConvergent(bool Value = true) {
2979c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsConvergent = Value;
2980c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2981c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2982c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2983c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setSExtResult(bool Value = true) {
2984c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      RetSExt = Value;
2985c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2986c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2987c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2988c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setZExtResult(bool Value = true) {
2989c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      RetZExt = Value;
2990c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2991c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2992c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2993c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setIsPatchPoint(bool Value = true) {
2994c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsPatchPoint = Value;
2995c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
2996c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
2997c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
2998c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CallLoweringInfo &setIsPostTypeLegalization(bool Value=true) {
2999c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      IsPostTypeLegalization = Value;
3000c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return *this;
3001c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
3002c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3003c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ArgListTy &getArgs() {
3004c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return Args;
3005c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    }
3006c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
3007c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3008c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This function lowers an abstract call to a function into an actual call.
3009c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This returns a pair of operands.  The first element is the return value
3010c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// for the function (if RetTy is not VoidTy).  The second element is the
3011c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// outgoing token chain. It calls LowerCall to do the actual lowering.
3012c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::pair<SDValue, SDValue> LowerCallTo(CallLoweringInfo &CLI) const;
3013c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3014c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This hook must be implemented to lower calls into the specified
3015c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// DAG. The outgoing arguments to the call are described by the Outs array,
3016c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// and the values to be returned by the call are described by the Ins
3017c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// array. The implementation should fill in the InVals array with legal-type
3018c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// return values from the call, and return the resulting token chain value.
3019c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue
3020c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    LowerCall(CallLoweringInfo &/*CLI*/,
3021c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot              SmallVectorImpl<SDValue> &/*InVals*/) const {
3022c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Not Implemented");
3023c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3024c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3025c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Target-specific cleanup for formal ByVal parameters.
3026c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void HandleByVal(CCState *, unsigned &, unsigned) const {}
3027c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3028c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This hook should be implemented to check whether the return values
3029c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// described by the Outs array can fit into the return registers.  If false
3030c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// is returned, an sret-demotion is performed.
3031c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool CanLowerReturn(CallingConv::ID /*CallConv*/,
3032c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              MachineFunction &/*MF*/, bool /*isVarArg*/,
3033c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot               const SmallVectorImpl<ISD::OutputArg> &/*Outs*/,
3034c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot               LLVMContext &/*Context*/) const
3035c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  {
3036c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Return true by default to get preexisting behavior.
3037c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return true;
3038c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3039c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3040c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This hook must be implemented to lower outgoing return values, described
3041c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// by the Outs array, into the specified DAG. The implementation should
3042c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// return the resulting token chain value.
3043c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue LowerReturn(SDValue /*Chain*/, CallingConv::ID /*CallConv*/,
3044c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              bool /*isVarArg*/,
3045c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const SmallVectorImpl<ISD::OutputArg> & /*Outs*/,
3046c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const SmallVectorImpl<SDValue> & /*OutVals*/,
3047c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              const SDLoc & /*dl*/,
3048c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                              SelectionDAG & /*DAG*/) const {
3049c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("Not Implemented");
3050c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3051c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3052c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if result of the specified node is used by a return node
3053c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// only. It also compute and return the input chain for the tail call.
3054c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
3055c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This is used to determine whether it is possible to codegen a libcall as
3056c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// tail call at legalization time.
3057c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool isUsedByReturnOnly(SDNode *, SDValue &/*Chain*/) const {
3058c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
3059c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3060c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3061c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return true if the target may be able emit the call instruction as a tail
3062c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// call. This is used by optimization passes to determine if it's profitable
3063c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to duplicate return instructions to enable tailcall optimization.
3064c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool mayBeEmittedAsTailCall(const CallInst *) const {
3065c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
3066c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3067c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3068c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the builtin name for the __builtin___clear_cache intrinsic
3069c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Default is to invoke the clear cache library call
3070c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const char * getClearCacheBuiltinName() const {
3071c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return "__clear_cache";
3072c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3073c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3074c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the register ID of the name passed in. Used by named register
3075c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// global variables extension. There is no target-independent behaviour
3076c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// so the default action is to bail.
3077c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getRegisterByName(const char* RegName, EVT VT,
3078c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     SelectionDAG &DAG) const {
3079c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    report_fatal_error("Named registers not implemented for this target");
3080c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3081c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3082c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return the type that should be used to zero or sign extend a
3083c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// zeroext/signext integer return value.  FIXME: Some C calling conventions
3084c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// require the return type to be promoted, but this is not true all the time,
3085c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// e.g. i1/i8/i16 on x86/x86_64. It is also not necessary for non-C calling
3086c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// conventions. The frontend should handle this and include all of the
3087c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// necessary information.
3088c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual EVT getTypeForExtReturn(LLVMContext &Context, EVT VT,
3089c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                       ISD::NodeType /*ExtendKind*/) const {
3090c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    EVT MinVT = getRegisterType(Context, MVT::i32);
3091c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return VT.bitsLT(MinVT) ? MinVT : VT;
3092c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3093c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3094c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For some targets, an LLVM struct type must be broken down into multiple
3095c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// simple types, but the calling convention specifies that the entire struct
3096c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// must be passed in a block of consecutive registers.
3097c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool
3098c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  functionArgumentNeedsConsecutiveRegisters(Type *Ty, CallingConv::ID CallConv,
3099c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            bool isVarArg) const {
3100c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
3101c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3102c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3103c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Returns a 0 terminated array of registers that can be safely used as
3104c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// scratch registers.
3105c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const MCPhysReg *getScratchRegisters(CallingConv::ID CC) const {
3106c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return nullptr;
3107c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3108c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3109c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This callback is used to prepare for a volatile or atomic load.
3110c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// It takes a chain node as input and returns the chain for the load itself.
3111c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
3112c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Having a callback like this is necessary for targets like SystemZ,
3113c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// which allows a CPU to reuse the result of a previous load indefinitely,
3114c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// even if a cache-coherent store is performed by another CPU.  The default
3115c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// implementation does nothing.
3116c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue prepareVolatileOrAtomicLoad(SDValue Chain, const SDLoc &DL,
3117c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                              SelectionDAG &DAG) const {
3118c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return Chain;
3119c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3120c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3121c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This callback is used to inspect load/store instructions and add
3122c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target-specific MachineMemOperand flags to them.  The default
3123c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// implementation does nothing.
3124c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MachineMemOperand::Flags getMMOFlags(const Instruction &I) const {
3125c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MachineMemOperand::MONone;
3126c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3127c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3128c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This callback is invoked by the type legalizer to legalize nodes with an
3129c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// illegal operand type but legal result types.  It replaces the
3130c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// LowerOperation callback in the type Legalizer.  The reason we can not do
3131c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// away with LowerOperation entirely is that LegalizeDAG isn't yet ready to
3132c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// use this callback.
3133c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
3134c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// TODO: Consider merging with ReplaceNodeResults.
3135c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
3136c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The target places new result values for the node in Results (their number
3137c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// and types must exactly match those of the original return values of
3138c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the node), or leaves Results empty, which indicates that the node is not
3139c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to be custom lowered after all.
3140c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The default implementation calls LowerOperation.
3141c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void LowerOperationWrapper(SDNode *N,
3142c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     SmallVectorImpl<SDValue> &Results,
3143c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                     SelectionDAG &DAG) const;
3144c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3145c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This callback is invoked for operations that are unsupported by the
3146c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target, which are registered to use 'custom' lowering, and whose defined
3147c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// values are all legal.  If the target has no operations that require custom
3148c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// lowering, it need not implement this.  The default implementation of this
3149c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// aborts.
3150c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
3151c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3152c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This callback is invoked when a node result type is illegal for the
3153c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target, and the operation was registered to use 'custom' lowering for that
3154c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// result type.  The target places new result values for the node in Results
3155c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// (their number and types must exactly match those of the original return
3156c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// values of the node), or leaves Results empty, which indicates that the
3157c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// node is not to be custom lowered after all.
3158c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
3159c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the target has no operations that require custom lowering, it need not
3160c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// implement this.  The default implementation aborts.
3161c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void ReplaceNodeResults(SDNode * /*N*/,
3162c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  SmallVectorImpl<SDValue> &/*Results*/,
3163c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  SelectionDAG &/*DAG*/) const {
3164c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    llvm_unreachable("ReplaceNodeResults not implemented for this target!");
3165c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3166c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3167c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method returns the name of a target specific DAG node.
3168c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const char *getTargetNodeName(unsigned Opcode) const;
3169c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3170c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method returns a target specific FastISel object, or null if the
3171c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// target does not support "fast" ISel.
3172c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual FastISel *createFastISel(FunctionLoweringInfo &,
3173c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                   const TargetLibraryInfo *) const {
3174c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return nullptr;
3175c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3176c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3177c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool verifyReturnAddressArgumentIsConstant(SDValue Op,
3178c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                             SelectionDAG &DAG) const;
3179c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3180c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
3181c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Inline Asm Support hooks
3182c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
3183c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3184c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This hook allows the target to expand an inline asm call to be explicit
3185c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// llvm code if it wants to.  This is useful for turning simple inline asms
3186c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// into LLVM intrinsics, which gives the compiler more information about the
3187c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// behavior of the code.
3188c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool ExpandInlineAsm(CallInst *) const {
3189c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
3190c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3191c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3192c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum ConstraintType {
3193c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    C_Register,            // Constraint represents specific register(s).
3194c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    C_RegisterClass,       // Constraint represents any of register(s) in class.
3195c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    C_Memory,              // Memory constraint.
3196c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    C_Other,               // Something else.
3197c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    C_Unknown              // Unsupported constraint.
3198c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
3199c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3200c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  enum ConstraintWeight {
3201c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Generic weights.
3202c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Invalid  = -1,     // No match.
3203c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Okay     = 0,      // Acceptable.
3204c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Good     = 1,      // Good weight.
3205c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Better   = 2,      // Better weight.
3206c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Best     = 3,      // Best weight.
3207c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3208c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Well-known weights.
3209c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_SpecificReg  = CW_Okay,    // Specific register operands.
3210c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Register     = CW_Good,    // Register operands.
3211c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Memory       = CW_Better,  // Memory operands.
3212c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Constant     = CW_Best,    // Constant operand.
3213c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    CW_Default      = CW_Okay     // Default or don't know type.
3214c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
3215c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3216c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This contains information for each constraint that we are lowering.
3217c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  struct AsmOperandInfo : public InlineAsm::ConstraintInfo {
3218c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// This contains the actual string for the code, like "m".  TargetLowering
3219c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// picks the 'best' code from ConstraintInfo::Codes that most closely
3220c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// matches the operand.
3221c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    std::string ConstraintCode;
3222c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3223c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Information about the constraint code, e.g. Register, RegisterClass,
3224c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Memory, Other, Unknown.
3225c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    TargetLowering::ConstraintType ConstraintType = TargetLowering::C_Unknown;
3226c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3227c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// If this is the result output operand or a clobber, this is null,
3228c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// otherwise it is the incoming operand to the CallInst.  This gets
3229c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// modified as the asm is processed.
3230c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Value *CallOperandVal = nullptr;
3231c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3232c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// The ValueType for the operand value.
3233c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    MVT ConstraintVT = MVT::Other;
3234c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3235c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Copy constructor for copying from a ConstraintInfo.
3236c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    AsmOperandInfo(InlineAsm::ConstraintInfo Info)
3237c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        : InlineAsm::ConstraintInfo(std::move(Info)) {}
3238c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3239c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// Return true of this is an input operand that is a matching constraint
3240c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// like "4".
3241c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    bool isMatchingInputConstraint() const;
3242c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3243c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// If this is an input matching constraint, this method returns the output
3244c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    /// operand it matches.
3245c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    unsigned getMatchedOperand() const;
3246c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  };
3247c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3248c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  using AsmOperandInfoVector = std::vector<AsmOperandInfo>;
3249c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3250c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Split up the constraint string from the inline assembly value into the
3251c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// specific constraints and their prefixes, and also tie in the associated
3252c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operand values.  If this returns an empty vector, and if the constraint
3253c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// string itself isn't empty, there was an error parsing.
3254c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual AsmOperandInfoVector ParseConstraints(const DataLayout &DL,
3255c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                const TargetRegisterInfo *TRI,
3256c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                ImmutableCallSite CS) const;
3257c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3258c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Examine constraint type and operand type and determine a weight value.
3259c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The operand object must already have been set up with the operand type.
3260c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual ConstraintWeight getMultipleConstraintMatchWeight(
3261c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      AsmOperandInfo &info, int maIndex) const;
3262c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3263c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Examine constraint string and operand type and determine a weight value.
3264c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The operand object must already have been set up with the operand type.
3265c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual ConstraintWeight getSingleConstraintMatchWeight(
3266c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      AsmOperandInfo &info, const char *constraint) const;
3267c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3268c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Determines the constraint code and constraint type to use for the specific
3269c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// AsmOperandInfo, setting OpInfo.ConstraintCode and OpInfo.ConstraintType.
3270c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If the actual operand being passed in is available, it can be passed in as
3271c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Op, otherwise an empty SDValue can be passed.
3272c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void ComputeConstraintToUse(AsmOperandInfo &OpInfo,
3273c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      SDValue Op,
3274c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                      SelectionDAG *DAG = nullptr) const;
3275c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3276c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Given a constraint, return the type of constraint it is for this target.
3277c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual ConstraintType getConstraintType(StringRef Constraint) const;
3278c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3279c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Given a physical register constraint (e.g.  {edx}), return the register
3280c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// number and the register class for the register.
3281c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
3282c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Given a register class constraint, like 'r', if this corresponds directly
3283c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// to an LLVM register class, return a register of 0 and the register class
3284c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// pointer.
3285c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
3286c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This should only be used for C_Register constraints.  On error, this
3287c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// returns a register number of 0 and a null register class pointer.
3288c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual std::pair<unsigned, const TargetRegisterClass *>
3289c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
3290c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               StringRef Constraint, MVT VT) const;
3291c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3292c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const {
3293c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    if (ConstraintCode == "i")
3294c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return InlineAsm::Constraint_i;
3295c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    else if (ConstraintCode == "m")
3296c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      return InlineAsm::Constraint_m;
3297c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return InlineAsm::Constraint_Unknown;
3298c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3299c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3300c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Try to replace an X constraint, which matches anything, with another that
3301c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// has more specific requirements based on the type of the corresponding
3302c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operand.  This returns null if there is no replacement to make.
3303c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual const char *LowerXConstraint(EVT ConstraintVT) const;
3304c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3305c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Lower the specified operand into the Ops vector.  If it is invalid, don't
3306c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// add anything to Ops.
3307c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
3308c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            std::vector<SDValue> &Ops,
3309c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                            SelectionDAG &DAG) const;
3310c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3311c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
3312c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Div utility functions
3313c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
3314c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue BuildSDIV(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
3315c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                    bool IsAfterLegalization,
3316c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                    std::vector<SDNode *> *Created) const;
3317c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue BuildUDIV(SDNode *N, const APInt &Divisor, SelectionDAG &DAG,
3318c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                    bool IsAfterLegalization,
3319c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                    std::vector<SDNode *> *Created) const;
3320c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3321c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Targets may override this function to provide custom SDIV lowering for
3322c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// power-of-2 denominators.  If the target returns an empty SDValue, LLVM
3323c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// assumes SDIV is expensive and replaces it with a series of other integer
3324c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operations.
3325c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue BuildSDIVPow2(SDNode *N, const APInt &Divisor,
3326c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                SelectionDAG &DAG,
3327c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                std::vector<SDNode *> *Created) const;
3328c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3329c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Indicate whether this target prefers to combine FDIVs with the same
3330c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// divisor. If the transform should never be done, return zero. If the
3331c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// transform should be done, return the minimum number of divisor uses
3332c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// that must exist.
3333c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual unsigned combineRepeatedFPDivisors() const {
3334c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return 0;
3335c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3336c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3337c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Hooks for building estimates in place of slower divisions and square
3338c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// roots.
3339c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3340c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return either a square root or its reciprocal estimate value for the input
3341c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// operand.
3342c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p Enabled is a ReciprocalEstimate enum with value either 'Unspecified' or
3343c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// 'Enabled' as set by a potential default override attribute.
3344c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If \p RefinementSteps is 'Unspecified', the number of Newton-Raphson
3345c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// refinement iterations required to generate a sufficient (though not
3346c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// necessarily IEEE-754 compliant) estimate is returned in that parameter.
3347c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The boolean UseOneConstNR output is used to select a Newton-Raphson
3348c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// algorithm implementation that uses either one or two constants.
3349c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// The boolean Reciprocal is used to select whether the estimate is for the
3350c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// square root of the input operand or the reciprocal of its square root.
3351c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// A target may choose to implement its own refinement within this function.
3352c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If that's true, then return '0' as the number of RefinementSteps to avoid
3353c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// any further refinement of the estimate.
3354c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// An empty SDValue return means no estimate sequence can be created.
3355c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue getSqrtEstimate(SDValue Operand, SelectionDAG &DAG,
3356c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  int Enabled, int &RefinementSteps,
3357c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  bool &UseOneConstNR, bool Reciprocal) const {
3358c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return SDValue();
3359c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3360c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3361c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Return a reciprocal estimate value for the input operand.
3362c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p Enabled is a ReciprocalEstimate enum with value either 'Unspecified' or
3363c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// 'Enabled' as set by a potential default override attribute.
3364c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If \p RefinementSteps is 'Unspecified', the number of Newton-Raphson
3365c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// refinement iterations required to generate a sufficient (though not
3366c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// necessarily IEEE-754 compliant) estimate is returned in that parameter.
3367c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// A target may choose to implement its own refinement within this function.
3368c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If that's true, then return '0' as the number of RefinementSteps to avoid
3369c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// any further refinement of the estimate.
3370c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// An empty SDValue return means no estimate sequence can be created.
3371c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue getRecipEstimate(SDValue Operand, SelectionDAG &DAG,
3372c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                   int Enabled, int &RefinementSteps) const {
3373c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return SDValue();
3374c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3375c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3376c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
3377c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Legalization utility functions
3378c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
3379c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3380c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Expand a MUL or [US]MUL_LOHI of n-bit values into two or four nodes,
3381c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// respectively, each computing an n/2-bit part of the result.
3382c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param Result A vector that will be filled with the parts of the result
3383c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///        in little-endian order.
3384c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param LL Low bits of the LHS of the MUL.  You can use this parameter
3385c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///        if you want to control how low bits are extracted from the LHS.
3386c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param LH High bits of the LHS of the MUL.  See LL for meaning.
3387c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param RL Low bits of the RHS of the MUL.  See LL for meaning
3388c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param RH High bits of the RHS of the MUL.  See LL for meaning.
3389c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \returns true if the node has been expanded, false if it has not
3390c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool expandMUL_LOHI(unsigned Opcode, EVT VT, SDLoc dl, SDValue LHS,
3391c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                      SDValue RHS, SmallVectorImpl<SDValue> &Result, EVT HiLoVT,
3392c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                      SelectionDAG &DAG, MulExpansionKind Kind,
3393c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                      SDValue LL = SDValue(), SDValue LH = SDValue(),
3394c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                      SDValue RL = SDValue(), SDValue RH = SDValue()) const;
3395c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3396c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Expand a MUL into two nodes.  One that computes the high bits of
3397c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the result and one that computes the low bits.
3398c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param HiLoVT The value type to use for the Lo and Hi nodes.
3399c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param LL Low bits of the LHS of the MUL.  You can use this parameter
3400c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///        if you want to control how low bits are extracted from the LHS.
3401c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param LH High bits of the LHS of the MUL.  See LL for meaning.
3402c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param RL Low bits of the RHS of the MUL.  See LL for meaning
3403c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param RH High bits of the RHS of the MUL.  See LL for meaning.
3404c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \returns true if the node has been expanded. false if it has not
3405c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool expandMUL(SDNode *N, SDValue &Lo, SDValue &Hi, EVT HiLoVT,
3406c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                 SelectionDAG &DAG, MulExpansionKind Kind,
3407c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                 SDValue LL = SDValue(), SDValue LH = SDValue(),
3408c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                 SDValue RL = SDValue(), SDValue RH = SDValue()) const;
3409c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3410c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Expand float(f32) to SINT(i64) conversion
3411c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param N Node to expand
3412c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param Result output after conversion
3413c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \returns True, if the expansion was successful, false otherwise
3414c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool expandFP_TO_SINT(SDNode *N, SDValue &Result, SelectionDAG &DAG) const;
3415c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3416c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Turn load of vector type into a load of the individual elements.
3417c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param LD load to expand
3418c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \returns MERGE_VALUEs of the scalar loads with their chains.
3419c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue scalarizeVectorLoad(LoadSDNode *LD, SelectionDAG &DAG) const;
3420c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3421c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Turn a store of a vector type into stores of the individual elements.
3422c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \param ST Store with a vector value type
3423c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \returns MERGE_VALUs of the individual store chains.
3424c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue scalarizeVectorStore(StoreSDNode *ST, SelectionDAG &DAG) const;
3425c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3426c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Expands an unaligned load to 2 half-size loads for an integer, and
3427c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// possibly more for vectors.
3428c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::pair<SDValue, SDValue> expandUnalignedLoad(LoadSDNode *LD,
3429c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                                  SelectionDAG &DAG) const;
3430c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3431c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Expands an unaligned store to 2 half-size stores for integer values, and
3432c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// possibly more for vectors.
3433c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue expandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG) const;
3434c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3435c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Increments memory address \p Addr according to the type of the value
3436c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p DataVT that should be stored. If the data is stored in compressed
3437c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// form, the memory address should be incremented according to the number of
3438c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the stored elements. This number is equal to the number of '1's bits
3439c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// in the \p Mask.
3440c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p DataVT is a vector type. \p Mask is a vector value.
3441c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// \p DataVT and \p Mask have the same number of vector elements.
3442c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue IncrementMemoryAddress(SDValue Addr, SDValue Mask, const SDLoc &DL,
3443c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                 EVT DataVT, SelectionDAG &DAG,
3444c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                 bool IsCompressedMemory) const;
3445c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3446c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Get a pointer to vector element \p Idx located in memory for a vector of
3447c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// type \p VecVT starting at a base address of \p VecPtr. If \p Idx is out of
3448c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// bounds the returned pointer is unspecified, but will be within the vector
3449c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// bounds.
3450c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue getVectorElementPointer(SelectionDAG &DAG, SDValue VecPtr, EVT VecVT,
3451c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                  SDValue Idx) const;
3452c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3453c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //===--------------------------------------------------------------------===//
3454c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Instruction Emitting Hooks
3455c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  //
3456c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3457c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method should be implemented by targets that mark instructions with
3458c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the 'usesCustomInserter' flag.  These instructions are special in various
3459c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ways, which require special support to insert.  The specified MachineInstr
3460c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// is created but not inserted into any basic blocks, and this method is
3461c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// called to expand it into a sequence of instructions, potentially also
3462c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// creating new basic blocks and control flow.
3463c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// As long as the returned basic block is different (i.e., we created a new
3464c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// one), the custom inserter is free to modify the rest of \p MBB.
3465c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MachineBasicBlock *
3466c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *MBB) const;
3467c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3468c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// This method should be implemented by targets that mark instructions with
3469c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the 'hasPostISelHook' flag. These instructions must be adjusted after
3470c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// instruction selection by target hooks.  e.g. To fill in optional defs for
3471c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// ARM 's' setting instructions.
3472c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual void AdjustInstrPostInstrSelection(MachineInstr &MI,
3473c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                             SDNode *Node) const;
3474c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3475c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// If this function returns true, SelectionDAGBuilder emits a
3476c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// LOAD_STACK_GUARD node when it is lowering Intrinsic::stackprotector.
3477c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool useLoadStackGuardNode() const {
3478c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
3479c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
3480c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3481c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// Lower TLS global address SDNode for target independent emulated TLS model.
3482c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual SDValue LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA,
3483c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                                          SelectionDAG &DAG) const;
3484c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3485c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // seteq(x, 0) -> truncate(srl(ctlz(zext(x)), log2(#bits)))
3486c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // If we're comparing for equality to zero and isCtlzFast is true, expose the
3487c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // fact that this can be implemented as a ctlz/srl pair, so that the dag
3488c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // combiner can fold the new nodes.
3489c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue lowerCmpEqZeroToCtlzSrl(SDValue Op, SelectionDAG &DAG) const;
3490c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3491c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
3492c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SDValue simplifySetCCWithAnd(EVT VT, SDValue N0, SDValue N1,
3493c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               ISD::CondCode Cond, DAGCombinerInfo &DCI,
3494c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                               const SDLoc &DL) const;
3495c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
3496c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3497c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// Given an LLVM IR type and return type attributes, compute the return value
3498c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// EVTs and flags, and optionally also the offsets, if the return value is
3499c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// being lowered to memory.
3500c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotvoid GetReturnInfo(Type *ReturnType, AttributeList attr,
3501c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                   SmallVectorImpl<ISD::OutputArg> &Outs,
3502c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                   const TargetLowering &TLI, const DataLayout &DL);
3503c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3504c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace llvm
3505c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
3506c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_TARGET_TARGETLOWERING_H
3507