================
@@ -0,0 +1,523 @@
+//===- 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/IR/DerivedTypes.h"
+#include "llvm/IR/Type.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/TargetParser/Triple.h"
+#include <cstdint>
+
+namespace llvm {
+namespace abi {
+
+enum class AVXABILevel { None, AVX, AVX512 };
+
+static unsigned getNativeVectorSizeForAVXABI(AVXABILevel AVXLevel) {
+  switch (AVXLevel) {
+  case AVXABILevel::AVX512:
+    return 512;
+  case AVXABILevel::AVX:
+    return 256;
+  case AVXABILevel::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:
+  AVXABILevel 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;
+
+  llvm::Type *getByteVectorType(const Type *Ty) const;
+  llvm::Type *getSseTypeAtOffset(llvm::Type *IRType, unsigned IROffset,
+                                 const Type *SourceTy,
+                                 unsigned SourceOffset) const;
+
+  llvm::Type *getIntegerTypeAtOffset(llvm::Type *IRType, unsigned IROffset,
+                                     const Type *SourceTy,
+                                     unsigned SourceOffset) const;
+
+  ABIArgInfo getIndirectReturnResult(const Type *Ty) const;
+
+  ABIArgInfo getIndirectResult(const Type *Ty, unsigned FreeIntRegs) const;
+
+  ABIArgInfo classifyReturnType(const Type *RetTy) const override;
+
+  ABIArgInfo classifyArgumentType(const Type *Ty, unsigned FreeIntRegs,
+                                  unsigned &NeededInt, unsigned &NeededSse,
+                                  bool IsNamedArg,
+                                  bool IsRegCall = false) const;
+
+  ABIArgInfo classifyRegCallStructType(const Type *Ty, unsigned &NeededInt,
+                                       unsigned &NeededSSE,
+                                       unsigned &MaxVectorWidth) const;
+
+  ABIArgInfo classifyRegCallStructTypeImpl(const Type *Ty, unsigned &NeededInt,
+                                           unsigned &NeededSSE,
+                                           unsigned &MaxVectorWidth) const;
+
+  bool isIllegalVectorType(const Type *Ty) const;
+
+  // The Functionality of these methods will be moved to
+  // llvm::abi::ABICompatInfo
+
+  bool honorsRevision98() const { return !TargetTriple.isOSDarwin(); }
+
+  bool classifyIntegerMMXAsSSE() const {
+    if (TargetTriple.isOSDarwin() || TargetTriple.isPS() ||
+        TargetTriple.isOSFreeBSD())
+      return false;
+    return true;
+  }
+
+  bool passInt128VectorsInMem() const {
+    // TODO: accept ABICompat info from the frontends
+    return TargetTriple.isOSLinux() || TargetTriple.isOSNetBSD();
+  }
+
+  bool returnCXXRecordGreaterThan128InMem() const {
+    // TODO: accept ABICompat info from the frontends
+    return true;
+  }
+
+public:
+  X86_64ABIInfo(const Triple &Triple, AVXABILevel AVXABILevel,
+                bool Has64BitPtrs, const ABICompatInfo &Compat)
+      : ABIInfo(Compat), AVXLevel(AVXABILevel), Has64BitPointers(Has64BitPtrs),
+        TargetTriple(Triple) {}
+
+  bool isPassedUsingAVXType(const Type *Type) const {
+    unsigned NeededInt, NeededSse;
+    ABIArgInfo Info = classifyArgumentType(Type, 0, NeededInt, NeededSse, 
true);
----------------
nikic wrote:

```suggestion
    ABIArgInfo Info = classifyArgumentType(Type, 0, NeededInt, NeededSse, 
/*IsNamedArg=*/true);
```

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