[PATCH] D21807: [Mips] Implement shouldSignExtI32Param hook.

Marcin Koƛcielnicki via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 28 11:10:09 PDT 2016


koriakin created this revision.
koriakin added a reviewer: dsanders.
koriakin added a subscriber: llvm-commits.
koriakin set the repository for this revision to rL LLVM.
Herald added a reviewer: vkalintiris.
Herald added subscribers: sdardis, dsanders.

On Mips, i32 parameters corresponding to C-level int or unsigned int
need signext attribute.  Fill the hook so that LLVM passes inserting
library calls with such parameters know to use the attribute.


Repository:
  rL LLVM

http://reviews.llvm.org/D21807

Files:
  lib/Target/Mips/MipsTargetMachine.cpp
  lib/Target/Mips/MipsTargetTransformInfo.h
  test/Instrumentation/InstrProfiling/icall.ll

Index: test/Instrumentation/InstrProfiling/icall.ll
===================================================================
--- test/Instrumentation/InstrProfiling/icall.ll
+++ test/Instrumentation/InstrProfiling/icall.ll
@@ -7,6 +7,8 @@
 ; RUN: opt < %s -mtriple=s390x-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT
 ; RUN: opt < %s -mtriple=powerpc64-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT
 ; RUN: opt < %s -mtriple=sparc64-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-EXT
+; RUN: opt < %s -mtriple=mips-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-SEXT
+; RUN: opt < %s -mtriple=mips64-unknown-linux -instrprof -vp-static-alloc=true -S | FileCheck %s --check-prefix=STATIC-SEXT
 ; RUN: opt < %s -mtriple=x86_64-apple-macosx10.10.0 -vp-static-alloc=false -instrprof -S | FileCheck %s --check-prefix=DYN
 ; RUN: opt < %s -mtriple=x86_64-unknown-linux -instrprof -vp-static-alloc=false -S | FileCheck %s --check-prefix=DYN
 
@@ -34,8 +36,11 @@
 
 ; DYN-NOT: @__profvp_foo
 ; DYN-NOT: @__llvm_prf_vnodes
+
 ; STATIC: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [1 x i16] }* @__profd_foo to i8*), i32 0)
 ; STATIC-EXT: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [1 x i16] }* @__profd_foo to i8*), i32 zeroext 0)
+; STATIC-SEXT: call void @__llvm_profile_instrument_target(i64 %3, i8* bitcast ({ i64, i64, i64*, i8*, i8*, i32, [1 x i16] }* @__profd_foo to i8*), i32 signext 0)
 
 ; STATIC: declare void @__llvm_profile_instrument_target(i64, i8*, i32)
 ; STATIC-EXT: declare void @__llvm_profile_instrument_target(i64, i8*, i32 zeroext)
+; STATIC-SEXT: declare void @__llvm_profile_instrument_target(i64, i8*, i32 signext)
Index: lib/Target/Mips/MipsTargetTransformInfo.h
===================================================================
--- /dev/null
+++ lib/Target/Mips/MipsTargetTransformInfo.h
@@ -0,0 +1,47 @@
+//===-- MipsTargetTransformInfo.h - Mips-specific TTI ---------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_MIPS_MIPSTARGETTRANSFORMINFO_H
+#define LLVM_LIB_TARGET_MIPS_MIPSTARGETTRANSFORMINFO_H
+
+#include "MipsTargetMachine.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/CodeGen/BasicTTIImpl.h"
+
+namespace llvm {
+
+class MipsTTIImpl : public BasicTTIImplBase<MipsTTIImpl> {
+  typedef BasicTTIImplBase<MipsTTIImpl> BaseT;
+  typedef TargetTransformInfo TTI;
+  friend BaseT;
+
+  const MipsSubtarget *ST;
+  const MipsTargetLowering *TLI;
+
+  const MipsSubtarget *getST() const { return ST; }
+  const MipsTargetLowering *getTLI() const { return TLI; }
+
+public:
+  explicit MipsTTIImpl(const MipsTargetMachine *TM, const Function &F)
+      : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
+        TLI(ST->getTargetLowering()) {}
+
+  // Provide value semantics. MSVC requires that we spell all of these out.
+  MipsTTIImpl(const MipsTTIImpl &Arg)
+      : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {}
+  MipsTTIImpl(MipsTTIImpl &&Arg)
+      : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)),
+        TLI(std::move(Arg.TLI)) {}
+
+  bool shouldSignExtI32Param() const { return true; }
+};
+
+} // end namespace llvm
+
+#endif
Index: lib/Target/Mips/MipsTargetMachine.cpp
===================================================================
--- lib/Target/Mips/MipsTargetMachine.cpp
+++ lib/Target/Mips/MipsTargetMachine.cpp
@@ -24,6 +24,7 @@
 #include "MipsSEISelLowering.h"
 #include "MipsSEInstrInfo.h"
 #include "MipsTargetObjectFile.h"
+#include "MipsTargetTransformInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
@@ -253,7 +254,7 @@
     }
 
     DEBUG(errs() << "Target Transform Info Pass Added\n");
-    return TargetTransformInfo(BasicTTIImpl(this, F));
+    return TargetTransformInfo(MipsTTIImpl(this, F));
   });
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21807.62117.patch
Type: text/x-patch
Size: 4380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160628/7fc56349/attachment.bin>


More information about the llvm-commits mailing list