================
@@ -0,0 +1,1493 @@
+//===- X86.cpp 
------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ABI/ABIFunctionInfo.h"
+#include "llvm/ABI/ABIInfo.h"
+#include "llvm/ABI/TargetCodegenInfo.h"
+#include "llvm/ABI/Types.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/IR/Type.h"
+#include "llvm/Support/Alignment.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/TypeSize.h"
+#include "llvm/TargetParser/Triple.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+
+namespace llvm {
+namespace abi {
+
+static unsigned getNativeVectorSizeForAVXABI(X86AVXABILevel AVXLevel) {
+  switch (AVXLevel) {
+  case X86AVXABILevel::AVX512:
+    return 512;
+  case X86AVXABILevel::AVX:
+    return 256;
+  case X86AVXABILevel::None:
+    return 128;
+  }
+  llvm_unreachable("Unknown AVXLevel");
+}
+
+class X86_64ABIInfo : public ABIInfo {
+public:
+  enum Class {
+    Integer = 0,
+    SSE,
+    SSEUp,
+    X87,
+    X87UP,
+    Complex_X87,
+    NoClass,
+    Memory
+  };
+
+private:
+  TypeBuilder &TB;
+  X86AVXABILevel AVXLevel;
+  bool Has64BitPointers;
+  const llvm::Triple &TargetTriple;
+
+  static Class merge(Class Accum, Class Field);
+
+  void postMerge(unsigned AggregateSize, Class &Lo, Class &Hi) const;
+
+  void classify(const Type *T, uint64_t OffsetBase, Class &Lo, Class &Hi,
+                bool IsNamedArg, bool IsRegCall = false) const;
+
+  const Type *getIntegerTypeAtOffset(const Type *IRType, unsigned IROffset,
+                                     const Type *SourceTy,
+                                     unsigned SourceOffset,
+                                     bool InMemory = false) const;
+
+  const Type *getSSETypeAtOffset(const Type *ABIType, unsigned ABIOffset,
+                                 const Type *SourceTy,
+                                 unsigned SourceOffset) const;
+  bool isIllegalVectorType(const Type *Ty) const;
+  bool containsMatrixField(const StructType *ST) const;
+
+  void computeInfo(ABIFunctionInfo &FI) const override;
+  ABIArgInfo getIndirectReturnResult(const Type *Ty) const;
+  const Type *getFPTypeAtOffset(const Type *Ty, unsigned Offset) const;
+
+  const Type *isSingleElementStruct(const Type *Ty) const;
+  const Type *getByteVectorType(const Type *Ty) const;
+
+  const Type *createPairType(const Type *Lo, const Type *Hi) const;
+  ABIArgInfo getIndirectResult(const Type *Ty, unsigned FreeIntRegs) const;
+
+  ABIArgInfo classifyReturnType(const Type *RetTy) const;
+  const char *getClassName(Class C) const;
+
+  ABIArgInfo classifyArgumentType(const Type *Ty, unsigned FreeIntRegs,
+                                  unsigned &NeededInt, unsigned &NeededSse,
+                                  bool IsNamedArg,
+                                  bool IsRegCall = false) const;
+  const Type *useFirstFieldIfTransparentUnion(const Type *Ty) const;
+
+public:
+  X86_64ABIInfo(TypeBuilder &TypeBuilder, const Triple &Triple,
+                X86AVXABILevel AVXABILevel, bool Has64BitPtrs,
+                const ABICompatInfo &Compat)
+      : ABIInfo(Compat), TB(TypeBuilder), AVXLevel(AVXABILevel),
+        Has64BitPointers(Has64BitPtrs), TargetTriple(Triple) {}
+
+  bool has64BitPointers() const { return Has64BitPointers; }
+};
+
+static bool isNamedMember(const FieldInfo &Field) {
+  if (Field.IsBitField && Field.IsUnnamedBitfield && Field.BitFieldWidth == 0) 
{
+    return false;
+  }
+
+  // A field is considered "named" if:
+  // The field itself has a name, OR
+  // The field is an unnamed struct/union that contains named data members
+  return Field.IsNamed || (!Field.IsNamed && Field.HasNamedDataMember);
+}
+
+// Gets the "best" type to represent the union.
+static const Type *reduceUnionForX8664(const StructType *UnionType,
+                                       TypeBuilder &TB) {
+  assert(UnionType->isUnion() && "Expected union type");
+  static llvm::DenseMap<const StructType *, const Type *> UnionReductionCache;
----------------
vortex73 wrote:

So Caching this does make a significant(I feel) performance difference on the 
compile time tracker...

https://github.com/llvm/llvm-project/pull/140112
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to