Fix build for C++20.
Nearly all changes are to the old LLVM sources. I largely did not
attempt to backport the upstream compile fixes, and simply fixed in
expedient ways. https://issuetracker.google.com/issues/268597958 covers
updating to a newer LLVM, which would contain the upstream fixes along
the way.
Bug: chromium:1284275
Change-Id: I32391593dfe052579a35083abc8a998da5d4667b
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/70768
Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
Presubmit-Ready: Shahbaz Youssefi <syoussefi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Commit-Queue: Peter Kasting <pkasting@google.com>
Tested-by: Peter Kasting <pkasting@google.com>
diff --git a/src/Device/BC_Decoder.cpp b/src/Device/BC_Decoder.cpp
index e77a1c1..b844ccb 100644
--- a/src/Device/BC_Decoder.cpp
+++ b/src/Device/BC_Decoder.cpp
@@ -1098,7 +1098,7 @@
int offset;
int count;
constexpr Bitfield Then(const int bits) { return { offset + count, bits }; }
- constexpr bool operator==(const Bitfield &rhs)
+ constexpr bool operator==(const Bitfield &rhs) const
{
return offset == rhs.offset && count == rhs.count;
}
diff --git a/third_party/llvm-10.0/llvm/include/llvm/ADT/IntervalMap.h b/third_party/llvm-10.0/llvm/include/llvm/ADT/IntervalMap.h
index a02876e..328f8fc 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/ADT/IntervalMap.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/ADT/IntervalMap.h
@@ -219,7 +219,7 @@
template <typename T1, typename T2, unsigned N>
class NodeBase {
public:
- enum { Capacity = N };
+ static constexpr unsigned Capacity = N;
T1 first[N];
T2 second[N];
diff --git a/third_party/llvm-10.0/llvm/include/llvm/Analysis/AliasAnalysis.h b/third_party/llvm-10.0/llvm/include/llvm/Analysis/AliasAnalysis.h
index 7c42a26..0bf979a 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -213,69 +213,70 @@
/// Loads from constant globals are not considered memory accesses for this
/// interface. Also, functions may freely modify stack space local to their
/// invocation without having to report it through these interfaces.
-enum FunctionModRefBehavior {
- /// This function does not perform any non-local loads or stores to memory.
- ///
- /// This property corresponds to the GCC 'const' attribute.
- /// This property corresponds to the LLVM IR 'readnone' attribute.
- /// This property corresponds to the IntrNoMem LLVM intrinsic flag.
- FMRB_DoesNotAccessMemory =
- FMRL_Nowhere | static_cast<int>(ModRefInfo::NoModRef),
+using FunctionModRefBehavior = int;
+/// This function does not perform any non-local loads or stores to memory.
+///
+/// This property corresponds to the GCC 'const' attribute.
+/// This property corresponds to the LLVM IR 'readnone' attribute.
+/// This property corresponds to the IntrNoMem LLVM intrinsic flag.
+constexpr FunctionModRefBehavior FMRB_DoesNotAccessMemory =
+ FMRL_Nowhere | static_cast<int>(ModRefInfo::NoModRef);
- /// The only memory references in this function (if it has any) are
- /// non-volatile loads from objects pointed to by its pointer-typed
- /// arguments, with arbitrary offsets.
- ///
- /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
- FMRB_OnlyReadsArgumentPointees =
- FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::Ref),
+/// The only memory references in this function (if it has any) are
+/// non-volatile loads from objects pointed to by its pointer-typed
+/// arguments, with arbitrary offsets.
+///
+/// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
+constexpr FunctionModRefBehavior FMRB_OnlyReadsArgumentPointees =
+ FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::Ref);
- /// The only memory references in this function (if it has any) are
- /// non-volatile loads and stores from objects pointed to by its
- /// pointer-typed arguments, with arbitrary offsets.
- ///
- /// This property corresponds to the IntrArgMemOnly LLVM intrinsic flag.
- FMRB_OnlyAccessesArgumentPointees =
- FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::ModRef),
+/// The only memory references in this function (if it has any) are
+/// non-volatile loads and stores from objects pointed to by its
+/// pointer-typed arguments, with arbitrary offsets.
+///
+/// This property corresponds to the IntrArgMemOnly LLVM intrinsic flag.
+constexpr FunctionModRefBehavior FMRB_OnlyAccessesArgumentPointees =
+ FMRL_ArgumentPointees | static_cast<int>(ModRefInfo::ModRef);
- /// The only memory references in this function (if it has any) are
- /// references of memory that is otherwise inaccessible via LLVM IR.
- ///
- /// This property corresponds to the LLVM IR inaccessiblememonly attribute.
- FMRB_OnlyAccessesInaccessibleMem =
- FMRL_InaccessibleMem | static_cast<int>(ModRefInfo::ModRef),
+/// The only memory references in this function (if it has any) are
+/// references of memory that is otherwise inaccessible via LLVM IR.
+///
+/// This property corresponds to the LLVM IR inaccessiblememonly attribute.
+constexpr FunctionModRefBehavior FMRB_OnlyAccessesInaccessibleMem =
+ FMRL_InaccessibleMem | static_cast<int>(ModRefInfo::ModRef);
- /// The function may perform non-volatile loads and stores of objects
- /// pointed to by its pointer-typed arguments, with arbitrary offsets, and
- /// it may also perform loads and stores of memory that is otherwise
- /// inaccessible via LLVM IR.
- ///
- /// This property corresponds to the LLVM IR
- /// inaccessiblemem_or_argmemonly attribute.
- FMRB_OnlyAccessesInaccessibleOrArgMem = FMRL_InaccessibleMem |
- FMRL_ArgumentPointees |
- static_cast<int>(ModRefInfo::ModRef),
+/// The function may perform non-volatile loads and stores of objects
+/// pointed to by its pointer-typed arguments, with arbitrary offsets, and
+/// it may also perform loads and stores of memory that is otherwise
+/// inaccessible via LLVM IR.
+///
+/// This property corresponds to the LLVM IR
+/// inaccessiblemem_or_argmemonly attribute.
+constexpr FunctionModRefBehavior FMRB_OnlyAccessesInaccessibleOrArgMem =
+ FMRL_InaccessibleMem | FMRL_ArgumentPointees |
+ static_cast<int>(ModRefInfo::ModRef);
- /// This function does not perform any non-local stores or volatile loads,
- /// but may read from any memory location.
- ///
- /// This property corresponds to the GCC 'pure' attribute.
- /// This property corresponds to the LLVM IR 'readonly' attribute.
- /// This property corresponds to the IntrReadMem LLVM intrinsic flag.
- FMRB_OnlyReadsMemory = FMRL_Anywhere | static_cast<int>(ModRefInfo::Ref),
+/// This function does not perform any non-local stores or volatile loads,
+/// but may read from any memory location.
+///
+/// This property corresponds to the GCC 'pure' attribute.
+/// This property corresponds to the LLVM IR 'readonly' attribute.
+/// This property corresponds to the IntrReadMem LLVM intrinsic flag.
+constexpr FunctionModRefBehavior FMRB_OnlyReadsMemory =
+ FMRL_Anywhere | static_cast<int>(ModRefInfo::Ref);
- // This function does not read from memory anywhere, but may write to any
- // memory location.
- //
- // This property corresponds to the LLVM IR 'writeonly' attribute.
- // This property corresponds to the IntrWriteMem LLVM intrinsic flag.
- FMRB_DoesNotReadMemory = FMRL_Anywhere | static_cast<int>(ModRefInfo::Mod),
+// This function does not read from memory anywhere, but may write to any
+// memory location.
+//
+// This property corresponds to the LLVM IR 'writeonly' attribute.
+// This property corresponds to the IntrWriteMem LLVM intrinsic flag.
+constexpr FunctionModRefBehavior FMRB_DoesNotReadMemory =
+ FMRL_Anywhere | static_cast<int>(ModRefInfo::Mod);
- /// This indicates that the function could not be classified into one of the
- /// behaviors above.
- FMRB_UnknownModRefBehavior =
- FMRL_Anywhere | static_cast<int>(ModRefInfo::ModRef)
-};
+/// This indicates that the function could not be classified into one of the
+/// behaviors above.
+constexpr FunctionModRefBehavior FMRB_UnknownModRefBehavior =
+ FMRL_Anywhere | static_cast<int>(ModRefInfo::ModRef);
// Wrapper method strips bits significant only in FunctionModRefBehavior,
// to obtain a valid ModRefInfo. The benefit of using the wrapper is that if
diff --git a/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/ELF.h b/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/ELF.h
index caab91d..25abbb2 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/ELF.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/ELF.h
@@ -1034,16 +1034,16 @@
};
// Symbol bindings.
-enum {
- STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def
- STB_GLOBAL = 1, // Global symbol, visible to all object files being combined
- STB_WEAK = 2, // Weak symbol, like global but lower-precedence
- STB_GNU_UNIQUE = 10,
- STB_LOOS = 10, // Lowest operating system-specific binding type
- STB_HIOS = 12, // Highest operating system-specific binding type
- STB_LOPROC = 13, // Lowest processor-specific binding type
- STB_HIPROC = 15 // Highest processor-specific binding type
-};
+constexpr int STB_LOCAL = 0; // Local symbol, not visible outside obj file
+ // containing def
+constexpr int STB_GLOBAL = 1; // Global symbol, visible to all object files
+ // being combined
+constexpr int STB_WEAK = 2; // Weak symbol, like global but lower-precedence
+constexpr int STB_GNU_UNIQUE = 10;
+constexpr int STB_LOOS = 10; // Lowest operating system-specific binding type
+constexpr int STB_HIOS = 12; // Highest operating system-specific binding type
+constexpr int STB_LOPROC = 13; // Lowest processor-specific binding type
+constexpr int STB_HIPROC = 15; // Highest processor-specific binding type
// Symbol types.
enum {
diff --git a/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/MachO.h b/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/MachO.h
index fb50e54..f03d084 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/MachO.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/BinaryFormat/MachO.h
@@ -172,44 +172,42 @@
LAST_KNOWN_SECTION_TYPE = S_THREAD_LOCAL_INIT_FUNCTION_POINTERS
};
-enum : uint32_t {
- // Constant masks for the "flags[31:24]" field in llvm::MachO::section and
- // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
+// Constant masks for the "flags[31:24]" field in llvm::MachO::section and
+// llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
- /// S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine
- /// instructions.
- S_ATTR_PURE_INSTRUCTIONS = 0x80000000u,
- /// S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be
- /// in a ranlib table of contents.
- S_ATTR_NO_TOC = 0x40000000u,
- /// S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section
- /// in files with the MY_DYLDLINK flag.
- S_ATTR_STRIP_STATIC_SYMS = 0x20000000u,
- /// S_ATTR_NO_DEAD_STRIP - No dead stripping.
- S_ATTR_NO_DEAD_STRIP = 0x10000000u,
- /// S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
- S_ATTR_LIVE_SUPPORT = 0x08000000u,
- /// S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by
- /// dyld.
- S_ATTR_SELF_MODIFYING_CODE = 0x04000000u,
- /// S_ATTR_DEBUG - A debug section.
- S_ATTR_DEBUG = 0x02000000u,
+/// S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine
+/// instructions.
+constexpr uint32_t S_ATTR_PURE_INSTRUCTIONS = 0x80000000u;
+/// S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be
+/// in a ranlib table of contents.
+constexpr uint32_t S_ATTR_NO_TOC = 0x40000000u;
+/// S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section
+/// in files with the MY_DYLDLINK flag.
+constexpr uint32_t S_ATTR_STRIP_STATIC_SYMS = 0x20000000u;
+/// S_ATTR_NO_DEAD_STRIP - No dead stripping.
+constexpr uint32_t S_ATTR_NO_DEAD_STRIP = 0x10000000u;
+/// S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
+constexpr uint32_t S_ATTR_LIVE_SUPPORT = 0x08000000u;
+/// S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by
+/// dyld.
+constexpr uint32_t S_ATTR_SELF_MODIFYING_CODE = 0x04000000u;
+/// S_ATTR_DEBUG - A debug section.
+constexpr uint32_t S_ATTR_DEBUG = 0x02000000u;
- // Constant masks for the "flags[23:8]" field in llvm::MachO::section and
- // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS)
+// Constant masks for the "flags[23:8]" field in llvm::MachO::section and
+// llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS)
- /// S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
- S_ATTR_SOME_INSTRUCTIONS = 0x00000400u,
- /// S_ATTR_EXT_RELOC - Section has external relocation entries.
- S_ATTR_EXT_RELOC = 0x00000200u,
- /// S_ATTR_LOC_RELOC - Section has local relocation entries.
- S_ATTR_LOC_RELOC = 0x00000100u,
+/// S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
+constexpr uint32_t S_ATTR_SOME_INSTRUCTIONS = 0x00000400u;
+/// S_ATTR_EXT_RELOC - Section has external relocation entries.
+constexpr uint32_t S_ATTR_EXT_RELOC = 0x00000200u;
+/// S_ATTR_LOC_RELOC - Section has local relocation entries.
+constexpr uint32_t S_ATTR_LOC_RELOC = 0x00000100u;
- // Constant masks for the value of an indirect symbol in an indirect
- // symbol table
- INDIRECT_SYMBOL_LOCAL = 0x80000000u,
- INDIRECT_SYMBOL_ABS = 0x40000000u
-};
+// Constant masks for the value of an indirect symbol in an indirect
+// symbol table
+constexpr uint32_t INDIRECT_SYMBOL_LOCAL = 0x80000000u;
+constexpr uint32_t INDIRECT_SYMBOL_ABS = 0x40000000u;
enum DataRegionType {
// Constants for the "kind" field in a data_in_code_entry structure
diff --git a/third_party/llvm-10.0/llvm/include/llvm/IR/InlineAsm.h b/third_party/llvm-10.0/llvm/include/llvm/IR/InlineAsm.h
index 72d8ad1..c3de548 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/IR/InlineAsm.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/IR/InlineAsm.h
@@ -203,68 +203,70 @@
// Else:
// Bit 30-16 - The register class ID to use for the operand.
- enum : uint32_t {
- // Fixed operands on an INLINEASM SDNode.
- Op_InputChain = 0,
- Op_AsmString = 1,
- Op_MDNode = 2,
- Op_ExtraInfo = 3, // HasSideEffects, IsAlignStack, AsmDialect.
- Op_FirstOperand = 4,
+ // Fixed operands on an INLINEASM SDNode.
+ static constexpr uint32_t Op_InputChain = 0;
+ static constexpr uint32_t Op_AsmString = 1;
+ static constexpr uint32_t Op_MDNode = 2;
+ static constexpr uint32_t Op_ExtraInfo = 3; // HasSideEffects, IsAlignStack,
+ // AsmDialect.
+ static constexpr uint32_t Op_FirstOperand = 4;
- // Fixed operands on an INLINEASM MachineInstr.
- MIOp_AsmString = 0,
- MIOp_ExtraInfo = 1, // HasSideEffects, IsAlignStack, AsmDialect.
- MIOp_FirstOperand = 2,
+ // Fixed operands on an INLINEASM MachineInstr.
+ static constexpr uint32_t MIOp_AsmString = 0;
+ static constexpr uint32_t MIOp_ExtraInfo = 1; // HasSideEffects,
+ // IsAlignStack, AsmDialect.
+ static constexpr uint32_t MIOp_FirstOperand = 2;
- // Interpretation of the MIOp_ExtraInfo bit field.
- Extra_HasSideEffects = 1,
- Extra_IsAlignStack = 2,
- Extra_AsmDialect = 4,
- Extra_MayLoad = 8,
- Extra_MayStore = 16,
- Extra_IsConvergent = 32,
+ // Interpretation of the MIOp_ExtraInfo bit field.
+ static constexpr uint32_t Extra_HasSideEffects = 1;
+ static constexpr uint32_t Extra_IsAlignStack = 2;
+ static constexpr uint32_t Extra_AsmDialect = 4;
+ static constexpr uint32_t Extra_MayLoad = 8;
+ static constexpr uint32_t Extra_MayStore = 16;
+ static constexpr uint32_t Extra_IsConvergent = 32;
- // Inline asm operands map to multiple SDNode / MachineInstr operands.
- // The first operand is an immediate describing the asm operand, the low
- // bits is the kind:
- Kind_RegUse = 1, // Input register, "r".
- Kind_RegDef = 2, // Output register, "=r".
- Kind_RegDefEarlyClobber = 3, // Early-clobber output register, "=&r".
- Kind_Clobber = 4, // Clobbered register, "~r".
- Kind_Imm = 5, // Immediate.
- Kind_Mem = 6, // Memory operand, "m".
+ // Inline asm operands map to multiple SDNode / MachineInstr operands.
+ // The first operand is an immediate describing the asm operand, the low
+ // bits is the kind:
+ static constexpr uint32_t Kind_RegUse = 1; // Input register, "r".
+ static constexpr uint32_t Kind_RegDef = 2; // Output register, "=r".
+ static constexpr uint32_t Kind_RegDefEarlyClobber = 3;
+ // Early-clobber output register,
+ // "=&r".
+ static constexpr uint32_t Kind_Clobber = 4; // Clobbered register, "~r".
+ static constexpr uint32_t Kind_Imm = 5; // Immediate.
+ static constexpr uint32_t Kind_Mem = 6; // Memory operand, "m".
- // Memory constraint codes.
- // These could be tablegenerated but there's little need to do that since
- // there's plenty of space in the encoding to support the union of all
- // constraint codes for all targets.
- Constraint_Unknown = 0,
- Constraint_es,
- Constraint_i,
- Constraint_m,
- Constraint_o,
- Constraint_v,
- Constraint_A,
- Constraint_Q,
- Constraint_R,
- Constraint_S,
- Constraint_T,
- Constraint_Um,
- Constraint_Un,
- Constraint_Uq,
- Constraint_Us,
- Constraint_Ut,
- Constraint_Uv,
- Constraint_Uy,
- Constraint_X,
- Constraint_Z,
- Constraint_ZC,
- Constraint_Zy,
- Constraints_Max = Constraint_Zy,
- Constraints_ShiftAmount = 16,
+ // Memory constraint codes.
+ // These could be tablegenerated but there's little need to do that since
+ // there's plenty of space in the encoding to support the union of all
+ // constraint codes for all targets.
+ static constexpr uint32_t Constraint_Unknown = 0;
+ static constexpr uint32_t Constraint_es = 1;
+ static constexpr uint32_t Constraint_i = 2;
+ static constexpr uint32_t Constraint_m = 3;
+ static constexpr uint32_t Constraint_o = 4;
+ static constexpr uint32_t Constraint_v = 5;
+ static constexpr uint32_t Constraint_A = 6;
+ static constexpr uint32_t Constraint_Q = 7;
+ static constexpr uint32_t Constraint_R = 8;
+ static constexpr uint32_t Constraint_S = 9;
+ static constexpr uint32_t Constraint_T = 10;
+ static constexpr uint32_t Constraint_Um = 11;
+ static constexpr uint32_t Constraint_Un = 12;
+ static constexpr uint32_t Constraint_Uq = 13;
+ static constexpr uint32_t Constraint_Us = 14;
+ static constexpr uint32_t Constraint_Ut = 15;
+ static constexpr uint32_t Constraint_Uv = 16;
+ static constexpr uint32_t Constraint_Uy = 17;
+ static constexpr uint32_t Constraint_X = 18;
+ static constexpr uint32_t Constraint_Z= 19;
+ static constexpr uint32_t Constraint_ZC = 20;
+ static constexpr uint32_t Constraint_Zy = 21;
+ static constexpr uint32_t Constraints_Max = Constraint_Zy;
+ static constexpr uint32_t Constraints_ShiftAmount = 16;
- Flag_MatchingOperand = 0x80000000
- };
+ static constexpr uint32_t Flag_MatchingOperand = 0x80000000;
static unsigned getFlagWord(unsigned Kind, unsigned NumOps) {
assert(((NumOps << 3) & ~0xffff) == 0 && "Too many inline asm operands!");
diff --git a/third_party/llvm-10.0/llvm/include/llvm/Support/BinaryStreamRef.h b/third_party/llvm-10.0/llvm/include/llvm/Support/BinaryStreamRef.h
index 5375d6a..24686c1 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/Support/BinaryStreamRef.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/Support/BinaryStreamRef.h
@@ -121,7 +121,7 @@
bool valid() const { return BorrowedImpl != nullptr; }
- bool operator==(const RefType &Other) const {
+ bool operator==(const BinaryStreamRefBase &Other) const {
if (BorrowedImpl != Other.BorrowedImpl)
return false;
if (ViewOffset != Other.ViewOffset)
diff --git a/third_party/llvm-10.0/llvm/include/llvm/Support/JSON.h b/third_party/llvm-10.0/llvm/include/llvm/Support/JSON.h
index 2c63468..c277baa 100644
--- a/third_party/llvm-10.0/llvm/include/llvm/Support/JSON.h
+++ b/third_party/llvm-10.0/llvm/include/llvm/Support/JSON.h
@@ -168,44 +168,36 @@
emplace_back(V);
}
- Value &operator[](size_t I) { return V[I]; }
- const Value &operator[](size_t I) const { return V[I]; }
- Value &front() { return V.front(); }
- const Value &front() const { return V.front(); }
- Value &back() { return V.back(); }
- const Value &back() const { return V.back(); }
- Value *data() { return V.data(); }
- const Value *data() const { return V.data(); }
+ Value &operator[](size_t I);
+ const Value &operator[](size_t I) const;
+ Value &front();
+ const Value &front() const;
+ Value &back();
+ const Value &back() const;
+ Value *data();
+ const Value *data() const;
- iterator begin() { return V.begin(); }
- const_iterator begin() const { return V.begin(); }
- iterator end() { return V.end(); }
- const_iterator end() const { return V.end(); }
+ iterator begin();
+ const_iterator begin() const;
+ iterator end();
+ const_iterator end() const;
- bool empty() const { return V.empty(); }
- size_t size() const { return V.size(); }
- void reserve(size_t S) { V.reserve(S); }
+ bool empty() const;
+ size_t size() const;
+ void reserve(size_t S);
- void clear() { V.clear(); }
- void push_back(const Value &E) { V.push_back(E); }
- void push_back(Value &&E) { V.push_back(std::move(E)); }
- template <typename... Args> void emplace_back(Args &&... A) {
- V.emplace_back(std::forward<Args>(A)...);
- }
- void pop_back() { V.pop_back(); }
+ void clear();
+ void push_back(const Value &E);
+ void push_back(Value &&E);
+ template <typename... Args> void emplace_back(Args &&...A);
+ void pop_back();
// FIXME: insert() takes const_iterator since C++11, old libstdc++ disagrees.
- iterator insert(iterator P, const Value &E) { return V.insert(P, E); }
- iterator insert(iterator P, Value &&E) {
- return V.insert(P, std::move(E));
- }
- template <typename It> iterator insert(iterator P, It A, It Z) {
- return V.insert(P, A, Z);
- }
- template <typename... Args> iterator emplace(const_iterator P, Args &&... A) {
- return V.emplace(P, std::forward<Args>(A)...);
- }
+ iterator insert(iterator P, const Value &E);
+ iterator insert(iterator P, Value &&E);
+ template <typename It> iterator insert(iterator P, It A, It Z);
+ template <typename... Args> iterator emplace(const_iterator P, Args &&...A);
- friend bool operator==(const Array &L, const Array &R) { return L.V == R.V; }
+ friend bool operator==(const Array &L, const Array &R);
};
inline bool operator!=(const Array &L, const Array &R) { return !(L == R); }
@@ -485,6 +477,48 @@
bool operator==(const Value &, const Value &);
inline bool operator!=(const Value &L, const Value &R) { return !(L == R); }
+// Array Methods
+inline Value &Array::operator[](size_t I) { return V[I]; }
+inline const Value &Array::operator[](size_t I) const { return V[I]; }
+inline Value &Array::front() { return V.front(); }
+inline const Value &Array::front() const { return V.front(); }
+inline Value &Array::back() { return V.back(); }
+inline const Value &Array::back() const { return V.back(); }
+inline Value *Array::data() { return V.data(); }
+inline const Value *Array::data() const { return V.data(); }
+
+inline typename Array::iterator Array::begin() { return V.begin(); }
+inline typename Array::const_iterator Array::begin() const { return V.begin(); }
+inline typename Array::iterator Array::end() { return V.end(); }
+inline typename Array::const_iterator Array::end() const { return V.end(); }
+
+inline bool Array::empty() const { return V.empty(); }
+inline size_t Array::size() const { return V.size(); }
+inline void Array::reserve(size_t S) { V.reserve(S); }
+
+inline void Array::clear() { V.clear(); }
+inline void Array::push_back(const Value &E) { V.push_back(E); }
+inline void Array::push_back(Value &&E) { V.push_back(std::move(E)); }
+template <typename... Args> inline void Array::emplace_back(Args &&...A) {
+ V.emplace_back(std::forward<Args>(A)...);
+}
+inline void Array::pop_back() { V.pop_back(); }
+inline typename Array::iterator Array::insert(iterator P, const Value &E) {
+ return V.insert(P, E);
+}
+inline typename Array::iterator Array::insert(iterator P, Value &&E) {
+ return V.insert(P, std::move(E));
+}
+template <typename It>
+inline typename Array::iterator Array::insert(iterator P, It A, It Z) {
+ return V.insert(P, A, Z);
+}
+template <typename... Args>
+inline typename Array::iterator Array::emplace(const_iterator P, Args &&...A) {
+ return V.emplace(P, std::forward<Args>(A)...);
+}
+inline bool operator==(const Array &L, const Array &R) { return L.V == R.V; }
+
/// ObjectKey is a used to capture keys in Object. Like Value but:
/// - only strings are allowed
/// - it's optimized for the string literal case (Owned == nullptr)
diff --git a/third_party/llvm-10.0/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/third_party/llvm-10.0/llvm/lib/CodeGen/PeepholeOptimizer.cpp
index c9c279c..68de770 100644
--- a/third_party/llvm-10.0/llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ b/third_party/llvm-10.0/llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -330,7 +330,7 @@
return RegSrcs[Idx].SubReg;
}
- bool operator==(const ValueTrackerResult &Other) {
+ bool operator==(const ValueTrackerResult &Other) const {
if (Other.getInst() != getInst())
return false;
diff --git a/third_party/llvm-10.0/llvm/lib/IR/Value.cpp b/third_party/llvm-10.0/llvm/lib/IR/Value.cpp
index cf9d08f..71b43c7 100644
--- a/third_party/llvm-10.0/llvm/lib/IR/Value.cpp
+++ b/third_party/llvm-10.0/llvm/lib/IR/Value.cpp
@@ -111,7 +111,7 @@
#include "llvm/IR/Value.def"
#define HANDLE_INST(N, OPC, CLASS) \
- case Value::InstructionVal + Instruction::OPC: \
+ case int{Value::InstructionVal} + Instruction::OPC: \
delete static_cast<CLASS *>(this); \
break;
#define HANDLE_USER_INST(N, OPC, CLASS)
diff --git a/third_party/llvm-10.0/llvm/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h b/third_party/llvm-10.0/llvm/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h
index d686a8e..266bd4d 100644
--- a/third_party/llvm-10.0/llvm/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h
+++ b/third_party/llvm-10.0/llvm/lib/Target/PowerPC/MCTargetDesc/PPCPredicates.h
@@ -23,48 +23,46 @@
namespace llvm {
namespace PPC {
/// Predicate - These are "(BI << 5) | BO" for various predicates.
- enum Predicate {
- PRED_LT = (0 << 5) | 12,
- PRED_LE = (1 << 5) | 4,
- PRED_EQ = (2 << 5) | 12,
- PRED_GE = (0 << 5) | 4,
- PRED_GT = (1 << 5) | 12,
- PRED_NE = (2 << 5) | 4,
- PRED_UN = (3 << 5) | 12,
- PRED_NU = (3 << 5) | 4,
- PRED_LT_MINUS = (0 << 5) | 14,
- PRED_LE_MINUS = (1 << 5) | 6,
- PRED_EQ_MINUS = (2 << 5) | 14,
- PRED_GE_MINUS = (0 << 5) | 6,
- PRED_GT_MINUS = (1 << 5) | 14,
- PRED_NE_MINUS = (2 << 5) | 6,
- PRED_UN_MINUS = (3 << 5) | 14,
- PRED_NU_MINUS = (3 << 5) | 6,
- PRED_LT_PLUS = (0 << 5) | 15,
- PRED_LE_PLUS = (1 << 5) | 7,
- PRED_EQ_PLUS = (2 << 5) | 15,
- PRED_GE_PLUS = (0 << 5) | 7,
- PRED_GT_PLUS = (1 << 5) | 15,
- PRED_NE_PLUS = (2 << 5) | 7,
- PRED_UN_PLUS = (3 << 5) | 15,
- PRED_NU_PLUS = (3 << 5) | 7,
+ using Predicate = int;
+ constexpr Predicate PRED_LT = (0 << 5) | 12;
+ constexpr Predicate PRED_LE = (1 << 5) | 4;
+ constexpr Predicate PRED_EQ = (2 << 5) | 12;
+ constexpr Predicate PRED_GE = (0 << 5) | 4;
+ constexpr Predicate PRED_GT = (1 << 5) | 12;
+ constexpr Predicate PRED_NE = (2 << 5) | 4;
+ constexpr Predicate PRED_UN = (3 << 5) | 12;
+ constexpr Predicate PRED_NU = (3 << 5) | 4;
+ constexpr Predicate PRED_LT_MINUS = (0 << 5) | 14;
+ constexpr Predicate PRED_LE_MINUS = (1 << 5) | 6;
+ constexpr Predicate PRED_EQ_MINUS = (2 << 5) | 14;
+ constexpr Predicate PRED_GE_MINUS = (0 << 5) | 6;
+ constexpr Predicate PRED_GT_MINUS = (1 << 5) | 14;
+ constexpr Predicate PRED_NE_MINUS = (2 << 5) | 6;
+ constexpr Predicate PRED_UN_MINUS = (3 << 5) | 14;
+ constexpr Predicate PRED_NU_MINUS = (3 << 5) | 6;
+ constexpr Predicate PRED_LT_PLUS = (0 << 5) | 15;
+ constexpr Predicate PRED_LE_PLUS = (1 << 5) | 7;
+ constexpr Predicate PRED_EQ_PLUS = (2 << 5) | 15;
+ constexpr Predicate PRED_GE_PLUS = (0 << 5) | 7;
+ constexpr Predicate PRED_GT_PLUS = (1 << 5) | 15;
+ constexpr Predicate PRED_NE_PLUS = (2 << 5) | 7;
+ constexpr Predicate PRED_UN_PLUS = (3 << 5) | 15;
+ constexpr Predicate PRED_NU_PLUS = (3 << 5) | 7;
- // SPE scalar compare instructions always set the GT bit.
- PRED_SPE = PRED_GT,
+ // SPE scalar compare instructions always set the GT bit.
+ constexpr Predicate PRED_SPE = PRED_GT;
- // When dealing with individual condition-register bits, we have simple set
- // and unset predicates.
- PRED_BIT_SET = 1024,
- PRED_BIT_UNSET = 1025
- };
+ // When dealing with individual condition-register bits, we have simple set
+ // and unset predicates.
+ constexpr Predicate PRED_BIT_SET = 1024;
+ constexpr Predicate PRED_BIT_UNSET = 1025;
// Bit for branch taken (plus) or not-taken (minus) hint
- enum BranchHintBit {
- BR_NO_HINT = 0x0,
- BR_NONTAKEN_HINT = 0x2,
- BR_TAKEN_HINT = 0x3,
- BR_HINT_MASK = 0X3
- };
+ using BranchHintBit = int;
+ constexpr BranchHintBit BR_NO_HINT = 0x0;
+ constexpr BranchHintBit BR_NONTAKEN_HINT = 0x2;
+ constexpr BranchHintBit BR_TAKEN_HINT = 0x3;
+ constexpr BranchHintBit BR_HINT_MASK = 0X3;
/// Invert the specified predicate. != -> ==, < -> >=.
Predicate InvertPredicate(Predicate Opcode);
diff --git a/third_party/llvm-subzero/include/llvm/ADT/STLExtras.h b/third_party/llvm-subzero/include/llvm/ADT/STLExtras.h
index e69bb6c..e641bc5 100644
--- a/third_party/llvm-subzero/include/llvm/ADT/STLExtras.h
+++ b/third_party/llvm-subzero/include/llvm/ADT/STLExtras.h
@@ -105,9 +105,9 @@
iterator_category;
typedef typename std::iterator_traits<RootIt>::difference_type
difference_type;
- typedef typename std::result_of<
- UnaryFunc(decltype(*std::declval<RootIt>()))>
- ::type value_type;
+ typedef typename std::invoke_result_t<UnaryFunc,
+ decltype(*std::declval<RootIt>())>
+ value_type;
typedef void pointer;
//typedef typename UnaryFunc::result_type *pointer;