[llvm-commits] [llvm] r41536 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/CodeGen/SimpleRegisterCoalescing.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp

2007-08-28 Thread Evan Cheng
Author: evancheng
Date: Tue Aug 28 03:28:51 2007
New Revision: 41536

URL: http://llvm.org/viewvc/llvm-project?rev=41536&view=rev
Log:
Recover most of the compile time regression due to recent live interval changes.
1. Eliminate the costly live interval "swapping".
2. Change ValueNumberInfo container from SmallVector to std::vector. The former
   performs slowly when the vector size is very large.

Modified:
llvm/trunk/include/llvm/CodeGen/LiveInterval.h
llvm/trunk/include/llvm/CodeGen/SimpleRegisterCoalescing.h
llvm/trunk/lib/CodeGen/LiveInterval.cpp
llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=41536&r1=41535&r2=41536&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
+++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Aug 28 03:28:51 2007
@@ -99,14 +99,19 @@
   VNInfo() : def(~1U), reg(0) {}
   VNInfo(unsigned d, unsigned r) : def(d), reg(r) {}
 };
-  private:
-SmallVector ValueNumberInfo;
-  public:
 
+typedef std::vector VNInfoList;
+VNInfoList ValueNumberInfo;
+
+  public:
 LiveInterval(unsigned Reg, float Weight)
   : reg(Reg), preference(0), weight(Weight) {
 }
 
+~LiveInterval() {
+  ValueNumberInfo.clear();
+}
+
 typedef Ranges::iterator iterator;
 iterator begin() { return ranges.begin(); }
 iterator end()   { return ranges.end(); }
@@ -115,6 +120,13 @@
 const_iterator begin() const { return ranges.begin(); }
 const_iterator end() const  { return ranges.end(); }
 
+typedef VNInfoList::iterator vni_iterator;
+vni_iterator vni_begin() { return ValueNumberInfo.begin(); }
+vni_iterator vni_end() { return ValueNumberInfo.end(); }
+
+typedef VNInfoList::const_iterator const_vni_iterator;
+const_vni_iterator vni_begin() const { return ValueNumberInfo.begin(); }
+const_vni_iterator vni_end() const { return ValueNumberInfo.end(); }
 
 /// advanceTo - Advance the specified iterator to point to the LiveRange
 /// containing the specified position, or end() if the position is past the
@@ -128,17 +140,37 @@
   return I;
 }
 
-void swap(LiveInterval& other) {
-  std::swap(reg, other.reg);
-  std::swap(weight, other.weight);
-  std::swap(ranges, other.ranges);
-  std::swap(ValueNumberInfo, other.ValueNumberInfo);
-}
-
 bool containsOneValue() const { return ValueNumberInfo.size() == 1; }
 
 unsigned getNumValNums() const { return ValueNumberInfo.size(); }
 
+/// getValNumInfo - Returns a copy of the specified val#.
+///
+inline VNInfo& getValNumInfo(unsigned ValNo) {
+  return ValueNumberInfo[ValNo];
+}
+inline const VNInfo& getValNumInfo(unsigned ValNo) const {
+  return ValueNumberInfo[ValNo];
+}
+
+/// copyValNumInfo - Copy the value number info for one value number to
+/// another.
+void copyValNumInfo(unsigned DstValNo, unsigned SrcValNo) {
+  VNInfo &vnd = getValNumInfo(DstValNo);
+  const VNInfo &vns = getValNumInfo(SrcValNo);
+  vnd.def = vns.def;
+  vnd.reg = vns.reg;
+  vnd.kills = vns.kills;
+}
+void copyValNumInfo(unsigned DstValNo, const LiveInterval &SrcLI,
+unsigned SrcValNo) {
+  VNInfo &vnd = getValNumInfo(DstValNo);
+  const VNInfo &vns = SrcLI.getValNumInfo(SrcValNo);
+  vnd.def = vns.def;
+  vnd.reg = vns.reg;
+  vnd.kills = vns.kills;
+}
+
 /// getNextValue - Create a new value number and return it.  MIIdx 
specifies
 /// the instruction that defines the value number.
 unsigned getNextValue(unsigned MIIdx, unsigned SrcReg) {
@@ -149,44 +181,38 @@
 /// getDefForValNum - Return the machine instruction index that defines the
 /// specified value number.
 unsigned getDefForValNum(unsigned ValNo) const {
-  assert(ValNo < ValueNumberInfo.size());
-  return ValueNumberInfo[ValNo].def;
+  return getValNumInfo(ValNo).def;
 }
 
 /// getSrcRegForValNum - If the machine instruction that defines the
 /// specified value number is a copy, returns the source register. 
Otherwise,
 /// returns zero.
 unsigned getSrcRegForValNum(unsigned ValNo) const {
-  assert(ValNo < ValueNumberInfo.size());
-  return ValueNumberInfo[ValNo].reg;
+  return getValNumInfo(ValNo).reg;
 }
 
 /// setDefForValNum - Set the machine instruction index that defines the
 /// specified value number. 
 void setDefForValNum(unsigned ValNo, unsigned NewDef) {
-  assert(ValNo < ValueNumberInfo.size());
-  ValueNumberInfo[ValNo].def = NewDef;
+  getValNumInfo(ValNo).def = NewDef;
 }
 
 /// setSrcRegForValNum - Set the source register of the specified value
 /// number. 
 void setSrcRe

Re: [llvm-commits] [llvm] r41489 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGISel.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/X86/memmove-0.ll test/CodeGen/X86/memmove-1.ll tes

2007-08-28 Thread Rafael Espindola
> I'm not aware of any cases where memmove vs. memcpy matters before
> codegen currently. If it were done at the LLVM IR level, would it be
> too trivial to be in a pass by itself, or would you want to add it,
> along with an addRequired, to some existing pass?

Doing it at the LLVM IL would also benefit non-DAG codegens (like the CBE).

> Dan
>

Cheers,
-- 
Rafael Avila de Espindola

Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland

Registered in Dublin, Ireland
Registration Number: 368047
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r41537 - in /llvm-gcc-4.2/trunk/gcc/config/i386: cygming.h t-cygming t-mingw32 winnt.c

2007-08-28 Thread Anton Korobeynikov
Author: asl
Date: Tue Aug 28 07:24:17 2007
New Revision: 41537

URL: http://llvm.org/viewvc/llvm-project?rev=41537&view=rev
Log:
Unbreak mingw32 build from merge bugs.

Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h
llvm-gcc-4.2/trunk/gcc/config/i386/t-cygming
llvm-gcc-4.2/trunk/gcc/config/i386/t-mingw32
llvm-gcc-4.2/trunk/gcc/config/i386/winnt.c

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h?rev=41537&r1=41536&r2=41537&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/cygming.h Tue Aug 28 07:24:17 2007
@@ -389,427 +389,15 @@
 #ifndef BUFSIZ
 # undef FILE
 #endif
-/* Operating system specific defines to be used when targeting GCC for
-   hosting on Windows32, using a Unix style C library and tools.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005
-   Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
-
-#define DBX_DEBUGGING_INFO 1
-#define SDB_DEBUGGING_INFO 1
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#ifdef HAVE_GAS_PE_SECREL32_RELOC
-#define DWARF2_DEBUGGING_INFO 1
-
-#undef DBX_REGISTER_NUMBER
-#define DBX_REGISTER_NUMBER(n) (write_symbols == DWARF2_DEBUG   \
-? svr4_dbx_register_map[n]  \
-: dbx_register_map[n])
-
-/* Use section relative relocations for debugging offsets.  Unlike
-   other targets that fake this by putting the section VMA at 0, PE
-   won't allow it.  */
-#define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION)\
-  do { \
-if (SIZE != 4) \
-  abort ();\
-   \
-fputs ("\t.secrel32\t", FILE); \
-assemble_name (FILE, LABEL);   \
-  } while (0)
-#endif
-
-#define TARGET_EXECUTABLE_SUFFIX ".exe"
-
-#include 
-
-#define MAYBE_UWIN_CPP_BUILTINS() /* Nothing.  */
-
-#define TARGET_OS_CPP_BUILTINS()   \
-  do   \
-{  \
-   builtin_define ("_X86_=1"); \
-   builtin_assert ("system=winnt");\
-   builtin_define ("__stdcall=__attribute__((__stdcall__))");  \
-   builtin_define ("__fastcall=__attribute__((__fastcall__))");\
-   builtin_define ("__cdecl=__attribute__((__cdecl__))");  \
-   if (!flag_iso)  \
- { \
-   builtin_define ("_stdcall=__attribute__((__stdcall__))");   \
-   builtin_define ("_fastcall=__attribute__((__fastcall__))"); \
-   builtin_define ("_cdecl=__attribute__((__cdecl__))");   \
- } \
-   /* Even though linkonce works with static libs, this is needed  \
-   to compare typeinfo symbols across dll boundaries.  */  \
-   builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0");   \
-   MAYBE_UWIN_CPP_BUILTINS (); \
-   EXTRA_OS_CPP_BUILTINS ();   \
-  }\
-  while (0)
-
-/* Get tree.c to declare a target-specific specialization of
-   merge_decl_attributes.  */
-#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
-
-/* This macro defines names of additional specifications to put in the specs
-   that can be used in various specifications like CC1_SPEC.  Its definition
-   is an initializer with a subgrouping for each command option.
-
-   Each subgrouping contains a string constant, that defines the
-   specification name, and a string constant that used by the GCC driver
-   program

Re: [llvm-commits] [patch] fix the alignment of i64 and f64 on linux x86-64

2007-08-28 Thread Dan Gohman
>> According to table 3.1 of http://www.x86-64.org/documentation/abi.pdf,
>> the i64 and f64 types should have 8 byte alignment.
>>
>> The attached patch changes this for targets that are not darwin.
> 
> Dan, Evan, is this ok?  Evan, doesn't darwin follow the same ABI on  
> x86-64?

It looks good to me.

Dan

-- 
Dan Gohman, Cray Inc.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r41538 - in /llvm-gcc-4.2/trunk/gcc: c-parser.c cp/parser.c

2007-08-28 Thread Anton Korobeynikov
Author: asl
Date: Tue Aug 28 10:57:24 2007
New Revision: 41538

URL: http://llvm.org/viewvc/llvm-project?rev=41538&view=rev
Log:
Fix handling of cw-style asm blocks.

Modified:
llvm-gcc-4.2/trunk/gcc/c-parser.c
llvm-gcc-4.2/trunk/gcc/cp/parser.c

Modified: llvm-gcc-4.2/trunk/gcc/c-parser.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-parser.c?rev=41538&r1=41537&r2=41538&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/c-parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-parser.c Tue Aug 28 10:57:24 2007
@@ -4464,12 +4464,14 @@
}
   return NULL_TREE;
 }
-  if (c_parser_next_token_is (parser, CPP_DOT)
-  || c_parser_next_token_is (parser, CPP_ATSIGN)
-  || c_parser_next_token_is (parser, CPP_NAME)
-  || c_parser_next_token_is_keyword (parser, RID_ASM)
-  || c_parser_next_token_is (parser, CPP_SEMICOLON)
-  || c_parser_iasm_bol (parser))
+  if (quals == NULL_TREE
+  && (c_parser_next_token_is (parser, CPP_DOT)
+ || c_parser_next_token_is (parser, CPP_ATSIGN)
+ || c_parser_next_token_is (parser, CPP_NAME)
+ || c_parser_next_token_is_keyword (parser, RID_ASM)
+ || c_parser_next_token_is (parser, CPP_SEMICOLON)
+ || (c_parser_iasm_bol (parser)
+ && ! c_parser_next_token_is (parser, CPP_OPEN_PAREN
 {
   if (flag_iasm_blocks)
c_parser_iasm_top_statement (parser);
@@ -5338,6 +5340,8 @@
  postfix-expression [ expression ]
  postfix-expression ( argument-expression-list[opt] )
  postfix-expression . identifier
+ APPLE LOCAL CW asm blocks
+ typedef-name . identifier
  postfix-expression -> identifier
  postfix-expression ++
  postfix-expression --
@@ -5351,7 +5355,11 @@
  argument-expression-list , argument-expression
 
primary-expression:
+ APPLE LOCAL CW asm blocks
+ .
  identifier
+ APPLE LOCAL CW asm blocks
+ @identifier
  constant
  string-literal
  ( expression )
@@ -5442,6 +5450,16 @@
   /* APPLE LOCAL end radar 5277239 */
   if (c_parser_peek_token (parser)->id_kind != C_ID_ID)
{
+ /* APPLE LOCAL begin CW asm blocks (in 4.2 bf) */
+ if (inside_iasm_block
+ && c_parser_peek_2nd_token (parser)->type == CPP_DOT)
+   {
+ expr.value = c_parser_peek_token (parser)->value;
+ expr.original_code = ERROR_MARK;
+ c_parser_consume_token (parser);
+ break;
+   }
+ /* APPLE LOCAL end CW asm blocks (in 4.2 bf) */
  c_parser_error (parser, "expected expression");
  expr.value = error_mark_node;
  expr.original_code = ERROR_MARK;
@@ -5828,6 +5846,29 @@
  expr.original_code = ERROR_MARK;
  break;
}
+ /* (in 4.2 be) */
+ if (c_parser_next_token_is (parser, CPP_ATSIGN))
+   {
+ tree id;
+ location_t loc = c_parser_peek_token (parser)->location;
+ c_parser_consume_token (parser);
+ if (c_parser_peek_token (parser)->id_kind != C_ID_ID)
+   {
+ c_parser_error (parser, "expected identifier");
+ expr.value = error_mark_node;
+ expr.original_code = ERROR_MARK;
+ break;
+   }
+
+ id = c_parser_peek_token (parser)->value;
+ c_parser_consume_token (parser);
+ id = prepend_char_identifier (id, '@');
+ expr.value = build_external_ref (id,
+  (c_parser_peek_token 
(parser)->type
+   == CPP_OPEN_PAREN), loc);
+ expr.original_code = ERROR_MARK;
+ break;
+   }
}
   /* APPLE LOCAL end CW asm blocks */
   c_parser_error (parser, "expected expression");
@@ -5882,6 +5923,11 @@
   tree ident, idx, exprlist;
   while (true)
 {
+  /* APPLE LOCAL begin CW asm blocks */
+  if (inside_iasm_block
+ && c_parser_iasm_bol (parser))
+   return expr;
+  /* APPLE LOCAL end CW asm blocks */
   switch (c_parser_peek_token (parser)->type)
{
case CPP_OPEN_SQUARE:
@@ -5894,6 +5940,10 @@
  expr.original_code = ERROR_MARK;
  break;
case CPP_OPEN_PAREN:
+ /* APPLE LOCAL begin CW asm blocks (in 4.2 bd) */
+ if (inside_iasm_block)
+   return expr;
+ /* APPLE LOCAL end CW asm blocks (in 4.2 bd) */
  /* Function call.  */
  c_parser_consume_token (parser);
  if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
@@ -5909,19 +5959,24 @@
  /* Structure element reference.  */
  c_parser_consume_token (parser);
  expr = default_function_array_conversion (expr);
- if (c_parser_next_token_is (parser, CPP_NAME))
-   ident = c_parse

[llvm-commits] [llvm-gcc-4.2] r41539 - /llvm-gcc-4.2/trunk/gcc/Makefile.in

2007-08-28 Thread Duncan Sands
Author: baldrick
Date: Tue Aug 28 11:11:02 2007
New Revision: 41539

URL: http://llvm.org/viewvc/llvm-project?rev=41539&view=rev
Log:
Forward port of r40542.
Restore llvm version info.

Modified:
llvm-gcc-4.2/trunk/gcc/Makefile.in

Modified: llvm-gcc-4.2/trunk/gcc/Makefile.in
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/Makefile.in?rev=41539&r1=41538&r2=41539&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/Makefile.in (original)
+++ llvm-gcc-4.2/trunk/gcc/Makefile.in Tue Aug 28 11:11:02 2007
@@ -231,10 +231,6 @@
 @checkingenabled_flag@
 LLVMOBJDIR = @LLVMBASEPATH@
 
-ifdef LLVM_VERSION_INFO
-CPPFLAGS += -DLLVM_VERSION_INFO='"$(LLVM_VERSION_INFO)"'
-endif
-
 # Determine BUILDMODE from configure run (--enable-llvm)
 BUILDMODE := @LLVMBUILDMODE@
 
@@ -249,6 +245,10 @@
 # srcdir != objdir builds.
 LLVMSRCDIR := $(shell $(LLVMBINPATH)/llvm-config --src-root)
 endif
+
+ifdef LLVM_VERSION_INFO
+CPPFLAGS += -DLLVM_VERSION_INFO='"$(LLVM_VERSION_INFO)"'
+endif
 # LLVM LOCAL end
 
 # These exists to be overridden by the x-* and t-* files, respectively.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r41553 - in /llvm/trunk/win32: Support/Support.vcproj Transforms/Transforms.vcproj VMCore/VMCore.vcproj x86/x86.vcproj

2007-08-28 Thread Chuck Rose III
Author: cfr
Date: Tue Aug 28 13:59:02 2007
New Revision: 41553

URL: http://llvm.org/viewvc/llvm-project?rev=41553&view=rev
Log:
Update win32 VStudio project files to keep pace with recently added and deleted 
files

Modified:
llvm/trunk/win32/Support/Support.vcproj
llvm/trunk/win32/Transforms/Transforms.vcproj
llvm/trunk/win32/VMCore/VMCore.vcproj
llvm/trunk/win32/x86/x86.vcproj

Modified: llvm/trunk/win32/Support/Support.vcproj
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/win32/Support/Support.vcproj?rev=41553&r1=41552&r2=41553&view=diff

==
--- llvm/trunk/win32/Support/Support.vcproj (original)
+++ llvm/trunk/win32/Support/Support.vcproj Tue Aug 28 13:59:02 2007
@@ -49,10 +49,11 @@
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
+   
ProgramDataBaseFileName="$(OutDir)\$(ProjectName).pdb"
BrowseInformation="1"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
-   DebugInformationFormat="4"
+   DebugInformationFormat="3"
DisableSpecificWarnings="4355,4146,4800"
/>



+   
+   

@@ -223,13 +229,6 @@

RelativePath="..\..\lib\Support\SlowOperationInformer.cpp"
>

-   
-   
-   
@@ -309,10 +308,6 @@
>


-   
-   

@@ -445,6 +440,10 @@
>


+   
+   


Modified: llvm/trunk/win32/Transforms/Transforms.vcproj
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/win32/Transforms/Transforms.vcproj?rev=41553&r1=41552&r2=41553&view=diff

==
--- llvm/trunk/win32/Transforms/Transforms.vcproj (original)
+++ llvm/trunk/win32/Transforms/Transforms.vcproj Tue Aug 28 13:59:02 2007
@@ -309,10 +309,6 @@
>


-   
-   

@@ -337,6 +333,10 @@
>


+   
+   

@@ -417,6 +417,10 @@
>


+   
+   


Modified: llvm/trunk/win32/VMCore/VMCore.vcproj
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/win32/VMCore/VMCore.vcproj?rev=41553&r1=41552&r2=41553&view=diff

==
--- llvm/trunk/win32/VMCore/VMCore.vcproj (original)
+++ llvm/trunk/win32/VMCore/VMCore.vcproj Tue Aug 28 13:59:02 2007
@@ -167,6 +167,10 @@
>


+   
+   


Modified: llvm/trunk/win32/x86/x86.vcproj
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/win32/x86/x86.vcproj?rev=41553&r1=41552&r2=41553&view=diff

==
--- llvm/trunk/win32/x86/x86.vcproj (original)
+++ llvm/trunk/win32/x86/x86.vcproj Tue Aug 28 13:59:02 2007
@@ -217,6 +217,10 @@
>


+   
+   



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] Trampoline support (pointers nested funtions)

2007-08-28 Thread Duncan Sands
Hi Evan, thanks for your comments.

> >> 3. In X86TargetLowering::LowerTRAMPOLINE():
> >> +case CallingConv::X86_StdCall: {
> >> +  Move = 0xb9; // Pass chain in ECX
> >>
> >> I assume this is the ModR/M byte?
> >
> > Well, it's MOV32ri.
> 
> Then it should be 0xb8?

It already had ECX or'd in.

> Please factor out getX86RegNum() as well. Perhaps put them in  
> X86RegisterInfo.cpp (since lowering really shouldn't depend on  
> codeemitter...) Do getX86RegNum(X86::EAX) rather than make use  
> N86::EAX directly.
...
> Please go through X86InstrInfo to get the opcode numbers instead of  
> hard coding it.

Does the attached patch seem OK?

Ciao,

Duncan.
Index: llvm.master/lib/Target/X86/X86CodeEmitter.cpp
===
--- llvm.master.orig/lib/Target/X86/X86CodeEmitter.cpp	2007-08-28 18:28:44.0 +0200
+++ llvm.master/lib/Target/X86/X86CodeEmitter.cpp	2007-08-28 19:10:26.0 +0200
@@ -13,7 +13,6 @@
 //===--===//
 
 #define DEBUG_TYPE "x86-emitter"
-#include "X86CodeEmitter.h"
 #include "X86InstrInfo.h"
 #include "X86Subtarget.h"
 #include "X86TargetMachine.h"
@@ -193,60 +192,8 @@
   MCE.emitWordLE(0); // The relocated value will be added to the displacement
 }
 
-// getX86RegNum - This function maps LLVM register identifiers to their X86
-// specific numbering, which is used in various places encoding instructions.
-//
 unsigned Emitter::getX86RegNum(unsigned RegNo) {
-  switch(RegNo) {
-  case X86::RAX: case X86::EAX: case X86::AX: case X86::AL: return N86::EAX;
-  case X86::RCX: case X86::ECX: case X86::CX: case X86::CL: return N86::ECX;
-  case X86::RDX: case X86::EDX: case X86::DX: case X86::DL: return N86::EDX;
-  case X86::RBX: case X86::EBX: case X86::BX: case X86::BL: return N86::EBX;
-  case X86::RSP: case X86::ESP: case X86::SP: case X86::SPL: case X86::AH:
-return N86::ESP;
-  case X86::RBP: case X86::EBP: case X86::BP: case X86::BPL: case X86::CH:
-return N86::EBP;
-  case X86::RSI: case X86::ESI: case X86::SI: case X86::SIL: case X86::DH:
-return N86::ESI;
-  case X86::RDI: case X86::EDI: case X86::DI: case X86::DIL: case X86::BH:
-return N86::EDI;
-
-  case X86::R8:  case X86::R8D:  case X86::R8W:  case X86::R8B:
-return N86::EAX;
-  case X86::R9:  case X86::R9D:  case X86::R9W:  case X86::R9B:
-return N86::ECX;
-  case X86::R10: case X86::R10D: case X86::R10W: case X86::R10B:
-return N86::EDX;
-  case X86::R11: case X86::R11D: case X86::R11W: case X86::R11B:
-return N86::EBX;
-  case X86::R12: case X86::R12D: case X86::R12W: case X86::R12B:
-return N86::ESP;
-  case X86::R13: case X86::R13D: case X86::R13W: case X86::R13B:
-return N86::EBP;
-  case X86::R14: case X86::R14D: case X86::R14W: case X86::R14B:
-return N86::ESI;
-  case X86::R15: case X86::R15D: case X86::R15W: case X86::R15B:
-return N86::EDI;
-
-  case X86::ST0: case X86::ST1: case X86::ST2: case X86::ST3:
-  case X86::ST4: case X86::ST5: case X86::ST6: case X86::ST7:
-return RegNo-X86::ST0;
-
-  case X86::XMM0:  case X86::XMM1:  case X86::XMM2:  case X86::XMM3:
-  case X86::XMM4:  case X86::XMM5:  case X86::XMM6:  case X86::XMM7:
-return II->getRegisterInfo().getDwarfRegNum(RegNo) -
-   II->getRegisterInfo().getDwarfRegNum(X86::XMM0);
-  case X86::XMM8:  case X86::XMM9:  case X86::XMM10: case X86::XMM11:
-  case X86::XMM12: case X86::XMM13: case X86::XMM14: case X86::XMM15:
-return II->getRegisterInfo().getDwarfRegNum(RegNo) -
-   II->getRegisterInfo().getDwarfRegNum(X86::XMM8);
-
-  default:
-assert(MRegisterInfo::isVirtualRegister(RegNo) &&
-   "Unknown physical register!");
-assert(0 && "Register allocator hasn't allocated reg correctly yet!");
-return 0;
-  }
+  return ((X86RegisterInfo&)II->getRegisterInfo()).getX86RegNum(RegNo);
 }
 
 inline static unsigned char ModRMByte(unsigned Mod, unsigned RegOpcode,
Index: llvm.master/lib/Target/X86/X86CodeEmitter.h
===
--- llvm.master.orig/lib/Target/X86/X86CodeEmitter.h	2007-08-28 18:31:01.0 +0200
+++ /dev/null	1970-01-01 00:00:00.0 +
@@ -1,25 +0,0 @@
-//===-- X86CodeEmitter.h - X86 DAG Lowering Interface ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by Duncan Sands and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===--===//
-//
-// This file defines utilities for X86 code emission.
-//
-//===--===//
-
-#ifndef X86CODEEMITTER_H
-#define X86CODEEMITTER_H
-
-/// N86 namespace - Native X86 Register numbers... used by X86 backend.
-///
-namespace N86 {
-  enum {
-EAX = 0, ECX = 1, EDX = 2, EBX = 

[llvm-commits] [llvm] r41556 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp

2007-08-28 Thread Dan Gohman
Author: djg
Date: Tue Aug 28 15:32:58 2007
New Revision: 41556

URL: http://llvm.org/viewvc/llvm-project?rev=41556&view=rev
Log:
Add an option, -view-sunit-dags, for viewing the actual SUnit DAGs used by
scheduling.

Modified:
llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=41556&r1=41555&r2=41556&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original)
+++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Tue Aug 28 15:32:58 2007
@@ -17,6 +17,7 @@
 
 #include "llvm/CodeGen/SelectionDAG.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/SmallSet.h"
 
 namespace llvm {
@@ -191,6 +192,11 @@
 
 virtual ~ScheduleDAG() {}
 
+/// viewGraph - Pop up a GraphViz/gv window with the ScheduleDAG rendered
+/// using 'dot'.
+///
+void viewGraph();
+  
 /// Run - perform scheduling.
 ///
 MachineBasicBlock *Run();
@@ -315,6 +321,68 @@
   ScheduleDAG* createDefaultScheduler(SelectionDAGISel *IS,
   SelectionDAG *DAG,
   MachineBasicBlock *BB);
+
+  class SUnitIterator : public forward_iterator {
+SUnit *Node;
+unsigned Operand;
+
+SUnitIterator(SUnit *N, unsigned Op) : Node(N), Operand(Op) {}
+  public:
+bool operator==(const SUnitIterator& x) const {
+  return Operand == x.Operand;
+}
+bool operator!=(const SUnitIterator& x) const { return !operator==(x); }
+
+const SUnitIterator &operator=(const SUnitIterator &I) {
+  assert(I.Node == Node && "Cannot assign iterators to two different 
nodes!");
+  Operand = I.Operand;
+  return *this;
+}
+
+pointer operator*() const {
+  return Node->Preds[Operand].first;
+}
+pointer operator->() const { return operator*(); }
+
+SUnitIterator& operator++() {// Preincrement
+  ++Operand;
+  return *this;
+}
+SUnitIterator operator++(int) { // Postincrement
+  SUnitIterator tmp = *this; ++*this; return tmp;
+}
+
+static SUnitIterator begin(SUnit *N) { return SUnitIterator(N, 0); }
+static SUnitIterator end  (SUnit *N) {
+  return SUnitIterator(N, N->Preds.size());
+}
+
+unsigned getOperand() const { return Operand; }
+const SUnit *getNode() const { return Node; }
+bool isChain() const { return Node->Preds[Operand].second; }
+  };
+
+  template <> struct GraphTraits {
+typedef SUnit NodeType;
+typedef SUnitIterator ChildIteratorType;
+static inline NodeType *getEntryNode(SUnit *N) { return N; }
+static inline ChildIteratorType child_begin(NodeType *N) {
+  return SUnitIterator::begin(N);
+}
+static inline ChildIteratorType child_end(NodeType *N) {
+  return SUnitIterator::end(N);
+}
+  };
+
+  template <> struct GraphTraits : public GraphTraits {
+typedef std::vector::iterator nodes_iterator;
+static nodes_iterator nodes_begin(ScheduleDAG *G) {
+  return G->SUnits.begin();
+}
+static nodes_iterator nodes_end(ScheduleDAG *G) {
+  return G->SUnits.end();
+}
+  };
 }
 
 #endif

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=41556&r1=41555&r2=41556&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Aug 28 
15:32:58 2007
@@ -54,8 +54,11 @@
 static cl::opt
 ViewSchedDAGs("view-sched-dags", cl::Hidden,
   cl::desc("Pop up a window to show sched dags as they are 
processed"));
+static cl::opt
+ViewSUnitDAGs("view-sunit-dags", cl::Hidden,
+  cl::desc("Pop up a window to show SUnit dags after they are 
processed"));
 #else
-static const bool ViewISelDAGs = 0, ViewSchedDAGs = 0;
+static const bool ViewISelDAGs = 0, ViewSchedDAGs = 0, ViewSUnitDAGs = 0;
 #endif
 
 //===-===//
@@ -4842,6 +4845,9 @@
   
   ScheduleDAG *SL = Ctor(this, &DAG, BB);
   BB = SL->Run();
+
+  if (ViewSUnitDAGs) SL->viewGraph();
+
   delete SL;
 }
 

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=41556&r1=41555&r2=41556&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/Selection