[llvm-commits] [llvm] r115393 - in /llvm/trunk: CMakeLists.txt lib/Target/MSP430/InstPrinter/CMakeLists.txt lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h lib/Target/MSP430/InstPrinter/Makefi

Nick Lewycky nlewycky at google.com
Mon Oct 4 17:55:19 PDT 2010


On 4 October 2010 17:37, Jim Grosbach <grosbach at apple.com> wrote:

> Re-applied as r115582.
>
> Works for me on OSX and Linux with both configure/make and CMake. Here's
> hoping the bots agree...
>

It builds on the system where I was reproducing it earlier. Thanks!!

Nick


> On Oct 3, 2010, at 11:39 PM, Nick Lewycky wrote:
>
> Here's what the GenLibDeps.pl script thinks is going on.
>
> libLLVMMSP430CodeGen.a uses but does not define symbols:
>   _ZN4llvm17MSP430InstPrinter15getRegisterNameEj aka.
> llvm::MSP430InstPrinter::getRegisterName(unsigned int)
> which are provided by libLLVMMSP430AsmPrinter.a. Going in the other
> direction, libLLVMMSP430AsmPrinter.a uses symbols:
>   _ZN4llvm6MSP43011GR8RegClassE aka. llvm::MSP430::GR8RegClass
>   _ZN4llvm6MSP43012GR16RegClassE aka. llvm::MSP430::GR16RegClass
>
> GR8RegClass and GR16RegClass is defined in MSP430RegisterInfo.o (which is
> rolled into ...CodeGen.a). Its only reference in ...AsmPrinter.a is by
> MSP430InstPrinter.o.
>
> The getRegisterName function is defined in MSP430InstPrinter.o (part of
> ...AsmPrinter.a) and its only reference in ...CodeGen.a is by
> MSP430AsmPrinter.o.
>
> Is that enough to go on?
>
> Nick
>
> On 1 October 2010 18:43, Nick Lewycky <nlewycky at google.com> wrote:
>
>> Okay. You can see that almost all of the open-source builders were broken:
>>
>>   http://google1.osuosl.org:8011/console
>>
>>  <http://google1.osuosl.org:8011/console>in that time. It's impossible
>> for this particular error to occur in a cmake build because cmake doesn't
>> run find-cycles.pl (last i checked). My suspicion is that the cmake
>> builders were working fine while configure+make ones were not?
>>
>> I'm going to wind back to the broken point and try to reproduce the
>> failure and see if I can figure out what the cyclic dependency actually was.
>>
>> Nick
>>
>>
>> On 1 October 2010 18:27, Jim Grosbach <grosbach at apple.com> wrote:
>>
>>> That's very strange. I do a configure/make here, and it works, and lots
>>> of bots using that were green as well. If there's a case I missed, I'd love
>>> to have some help tracking down what it is. Can you try a "make clean" and
>>> see if that works? Maybe there's just something stale that the configure
>>> portion of the patch needs to clean up.
>>>
>>> -Jim
>>>
>>>
>>>
>>> On Oct 1, 2010, at 6:24 PM, Nick Lewycky wrote:
>>>
>>> Nope, it broke under a regular configure+make in-srctree incremental
>>> build on multiple different machines.
>>>
>>> On 1 October 2010 18:22, Jim Grosbach <grosbach at apple.com> wrote:
>>>
>>>> Nick,
>>>>
>>>> These only break for you under CMake, right? That's the only place I've
>>>> been able to reproduce failures.
>>>>
>>>> -Jim
>>>>
>>>>
>>>> On Oct 1, 2010, at 6:06 PM, Nick Lewycky wrote:
>>>>
>>>> > Author: nicholas
>>>> > Date: Fri Oct  1 20:06:42 2010
>>>> > New Revision: 115393
>>>> >
>>>> > URL: http://llvm.org/viewvc/llvm-project?rev=115393&view=rev
>>>> > Log:
>>>> > Revert patches r115363 r115367 r115391 due to build breakage:
>>>> > llvm[2]: Updated LibDeps.txt because dependencies changed
>>>> > llvm[2]: Checking for cyclic dependencies between LLVM libraries.
>>>> > find-cycles.pl: Circular dependency between *.a files:
>>>> > find-cycles.pl:   libLLVMMSP430AsmPrinter.a libLLVMMSP430CodeGen.a
>>>> >
>>>> >
>>>> > Modified:
>>>> >    llvm/trunk/CMakeLists.txt
>>>> >    llvm/trunk/lib/Target/MSP430/InstPrinter/CMakeLists.txt
>>>> >    llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
>>>> >    llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h
>>>> >    llvm/trunk/lib/Target/MSP430/InstPrinter/Makefile
>>>> >    llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp
>>>> >    llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp
>>>> >    llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.h
>>>> >    llvm/trunk/lib/Target/MSP430/Makefile
>>>> >
>>>> > Modified: llvm/trunk/CMakeLists.txt
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/CMakeLists.txt (original)
>>>> > +++ llvm/trunk/CMakeLists.txt Fri Oct  1 20:06:42 2010
>>>> > @@ -323,10 +323,6 @@
>>>> >     add_subdirectory(lib/Target/${t}/AsmPrinter)
>>>> >     set(LLVM_ENUM_ASM_PRINTERS
>>>> >       "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n")
>>>> > -  if( EXISTS
>>>> ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/InstPrinter/CMakeLists.txt )
>>>> > -    add_subdirectory(lib/Target/${t}/InstPrinter)
>>>> > -    set(LLVM_ENUM_ASM_PRINTERS
>>>> > -      "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n")
>>>> >   endif( EXISTS
>>>> ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
>>>> >   if( EXISTS
>>>> ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmParser/CMakeLists.txt )
>>>> >     add_subdirectory(lib/Target/${t}/AsmParser)
>>>> >
>>>> > Modified: llvm/trunk/lib/Target/MSP430/InstPrinter/CMakeLists.txt
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/InstPrinter/CMakeLists.txt?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/InstPrinter/CMakeLists.txt (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/InstPrinter/CMakeLists.txt Fri Oct  1
>>>> 20:06:42 2010
>>>> > @@ -1,6 +0,0 @@
>>>> > -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/..
>>>> ${CMAKE_CURRENT_SOURCE_DIR}/.. )
>>>> > -
>>>> > -add_llvm_library(LLVMMSP430AsmPrinter
>>>> > -  MSP430InstPrinter.cpp
>>>> > -  )
>>>> > -add_dependencies(LLVMMSP430AsmPrinter MSP430CodeGenTable_gen)
>>>> >
>>>> > Modified:
>>>> llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp
>>>> (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.cpp Fri
>>>> Oct  1 20:06:42 2010
>>>> > @@ -1,114 +0,0 @@
>>>> > -//===-- MSP430InstPrinter.cpp - Convert MSP430 MCInst to assembly
>>>> syntax --===//
>>>> > -//
>>>> > -//                     The LLVM Compiler Infrastructure
>>>> > -//
>>>> > -// This file is distributed under the University of Illinois Open
>>>> Source
>>>> > -// License. See LICENSE.TXT for details.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -//
>>>> > -// This class prints an MSP430 MCInst to a .s file.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -
>>>> > -#define DEBUG_TYPE "asm-printer"
>>>> > -#include "MSP430.h"
>>>> > -#include "MSP430InstrInfo.h"
>>>> > -#include "MSP430InstPrinter.h"
>>>> > -#include "llvm/MC/MCInst.h"
>>>> > -#include "llvm/MC/MCAsmInfo.h"
>>>> > -#include "llvm/MC/MCExpr.h"
>>>> > -#include "llvm/Support/ErrorHandling.h"
>>>> > -#include "llvm/Support/FormattedStream.h"
>>>> > -using namespace llvm;
>>>> > -
>>>> > -
>>>> > -// Include the auto-generated portion of the assembly writer.
>>>> > -#include "MSP430GenAsmWriter.inc"
>>>> > -
>>>> > -void MSP430InstPrinter::printInst(const MCInst *MI, raw_ostream &O) {
>>>> > -  printInstruction(MI, O);
>>>> > -}
>>>> > -
>>>> > -void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI,
>>>> unsigned OpNo,
>>>> > -                                             raw_ostream &O) {
>>>> > -  const MCOperand &Op = MI->getOperand(OpNo);
>>>> > -  if (Op.isImm())
>>>> > -    O << Op.getImm();
>>>> > -  else {
>>>> > -    assert(Op.isExpr() && "unknown pcrel immediate operand");
>>>> > -    O << *Op.getExpr();
>>>> > -  }
>>>> > -}
>>>> > -
>>>> > -void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
>>>> > -                                     raw_ostream &O, const char
>>>> *Modifier) {
>>>> > -  assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers
>>>> supported");
>>>> > -  const MCOperand &Op = MI->getOperand(OpNo);
>>>> > -  if (Op.isReg()) {
>>>> > -    O << getRegisterName(Op.getReg());
>>>> > -  } else if (Op.isImm()) {
>>>> > -    O << '#' << Op.getImm();
>>>> > -  } else {
>>>> > -    assert(Op.isExpr() && "unknown operand kind in printOperand");
>>>> > -    O << '#' << *Op.getExpr();
>>>> > -  }
>>>> > -}
>>>> > -
>>>> > -void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned
>>>> OpNo,
>>>> > -                                           raw_ostream &O,
>>>> > -                                           const char *Modifier) {
>>>> > -  const MCOperand &Base = MI->getOperand(OpNo);
>>>> > -  const MCOperand &Disp = MI->getOperand(OpNo+1);
>>>> > -
>>>> > -  // Print displacement first
>>>> > -
>>>> > -  // If the global address expression is a part of displacement field
>>>> with a
>>>> > -  // register base, we should not emit any prefix symbol here, e.g.
>>>> > -  //   mov.w &foo, r1
>>>> > -  // vs
>>>> > -  //   mov.w glb(r1), r2
>>>> > -  // Otherwise (!) msp430-as will silently miscompile the output :(
>>>> > -  if (!Base.getReg())
>>>> > -    O << '&';
>>>> > -
>>>> > -  if (Disp.isExpr())
>>>> > -    O << *Disp.getExpr();
>>>> > -  else {
>>>> > -    assert(Disp.isImm() && "Expected immediate in displacement
>>>> field");
>>>> > -    O << Disp.getImm();
>>>> > -  }
>>>> > -
>>>> > -  // Print register base field
>>>> > -  if (Base.getReg())
>>>> > -    O << '(' << getRegisterName(Base.getReg()) << ')';
>>>> > -}
>>>> > -
>>>> > -void MSP430InstPrinter::printCCOperand(const MCInst *MI, unsigned
>>>> OpNo,
>>>> > -                                       raw_ostream &O) {
>>>> > -  unsigned CC = MI->getOperand(OpNo).getImm();
>>>> > -
>>>> > -  switch (CC) {
>>>> > -  default:
>>>> > -   llvm_unreachable("Unsupported CC code");
>>>> > -   break;
>>>> > -  case MSP430CC::COND_E:
>>>> > -   O << "eq";
>>>> > -   break;
>>>> > -  case MSP430CC::COND_NE:
>>>> > -   O << "ne";
>>>> > -   break;
>>>> > -  case MSP430CC::COND_HS:
>>>> > -   O << "hs";
>>>> > -   break;
>>>> > -  case MSP430CC::COND_LO:
>>>> > -   O << "lo";
>>>> > -   break;
>>>> > -  case MSP430CC::COND_GE:
>>>> > -   O << "ge";
>>>> > -   break;
>>>> > -  case MSP430CC::COND_L:
>>>> > -   O << 'l';
>>>> > -   break;
>>>> > -  }
>>>> > -}
>>>> >
>>>> > Modified: llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h
>>>> (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h Fri
>>>> Oct  1 20:06:42 2010
>>>> > @@ -1,43 +0,0 @@
>>>> > -//===-- MSP430InstPrinter.h - Convert MSP430 MCInst to assembly
>>>> syntax ----===//
>>>> > -//
>>>> > -//                     The LLVM Compiler Infrastructure
>>>> > -//
>>>> > -// This file is distributed under the University of Illinois Open
>>>> Source
>>>> > -// License. See LICENSE.TXT for details.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -//
>>>> > -// This class prints a MSP430 MCInst to a .s file.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -
>>>> > -#ifndef MSP430INSTPRINTER_H
>>>> > -#define MSP430INSTPRINTER_H
>>>> > -
>>>> > -#include "llvm/MC/MCInstPrinter.h"
>>>> > -
>>>> > -namespace llvm {
>>>> > -  class MCOperand;
>>>> > -
>>>> > -  class MSP430InstPrinter : public MCInstPrinter {
>>>> > -  public:
>>>> > -    MSP430InstPrinter(const MCAsmInfo &MAI) : MCInstPrinter(MAI) {
>>>> > -    }
>>>> > -
>>>> > -    virtual void printInst(const MCInst *MI, raw_ostream &O);
>>>> > -
>>>> > -    // Autogenerated by tblgen.
>>>> > -    void printInstruction(const MCInst *MI, raw_ostream &O);
>>>> > -    static const char *getRegisterName(unsigned RegNo);
>>>> > -
>>>> > -    void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream
>>>> &O,
>>>> > -                      const char *Modifier = 0);
>>>> > -    void printPCRelImmOperand(const MCInst *MI, unsigned OpNo,
>>>> raw_ostream &O);
>>>> > -    void printSrcMemOperand(const MCInst *MI, unsigned OpNo,
>>>> raw_ostream &O,
>>>> > -                            const char *Modifier = 0);
>>>> > -    void printCCOperand(const MCInst *MI, unsigned OpNo, raw_ostream
>>>> &O);
>>>> > -
>>>> > -  };
>>>> > -}
>>>> > -
>>>> > -#endif
>>>> >
>>>> > Modified: llvm/trunk/lib/Target/MSP430/InstPrinter/Makefile
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/InstPrinter/Makefile?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/InstPrinter/Makefile (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/InstPrinter/Makefile Fri Oct  1
>>>> 20:06:42 2010
>>>> > @@ -1,15 +0,0 @@
>>>> > -##===- lib/Target/MSP430/AsmPrinter/Makefile ---------------*-
>>>> Makefile -*-===##
>>>> > -#
>>>> > -#                     The LLVM Compiler Infrastructure
>>>> > -#
>>>> > -# This file is distributed under the University of Illinois Open
>>>> Source
>>>> > -# License. See LICENSE.TXT for details.
>>>> > -#
>>>> >
>>>> -##===----------------------------------------------------------------------===##
>>>> > -LEVEL = ../../../..
>>>> > -LIBRARYNAME = LLVMMSP430AsmPrinter
>>>> > -
>>>> > -# Hack: we need to include 'main' MSP430 target directory to grab
>>>> private headers
>>>> > -CPP.Flags += -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
>>>> > -
>>>> > -include $(LEVEL)/Makefile.common
>>>> >
>>>> > Modified: llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp Fri Oct  1
>>>> 20:06:42 2010
>>>> > @@ -1,179 +0,0 @@
>>>> > -//===-- MSP430AsmPrinter.cpp - MSP430 LLVM assembly writer
>>>> ----------------===//
>>>> > -//
>>>> > -//                     The LLVM Compiler Infrastructure
>>>> > -//
>>>> > -// This file is distributed under the University of Illinois Open
>>>> Source
>>>> > -// License. See LICENSE.TXT for details.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -//
>>>> > -// This file contains a printer that converts from our internal
>>>> representation
>>>> > -// of machine-dependent LLVM code to the MSP430 assembly language.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -
>>>> > -#define DEBUG_TYPE "asm-printer"
>>>> > -#include "MSP430.h"
>>>> > -#include "MSP430InstrInfo.h"
>>>> > -#include "InstPrinter/MSP430InstPrinter.h"
>>>> > -#include "MSP430MCAsmInfo.h"
>>>> > -#include "MSP430MCInstLower.h"
>>>> > -#include "MSP430TargetMachine.h"
>>>> > -#include "llvm/Constants.h"
>>>> > -#include "llvm/DerivedTypes.h"
>>>> > -#include "llvm/Module.h"
>>>> > -#include "llvm/Assembly/Writer.h"
>>>> > -#include "llvm/CodeGen/AsmPrinter.h"
>>>> > -#include "llvm/CodeGen/MachineModuleInfo.h"
>>>> > -#include "llvm/CodeGen/MachineFunctionPass.h"
>>>> > -#include "llvm/CodeGen/MachineConstantPool.h"
>>>> > -#include "llvm/CodeGen/MachineInstr.h"
>>>> > -#include "llvm/MC/MCInst.h"
>>>> > -#include "llvm/MC/MCStreamer.h"
>>>> > -#include "llvm/MC/MCSymbol.h"
>>>> > -#include "llvm/Target/Mangler.h"
>>>> > -#include "llvm/Target/TargetData.h"
>>>> > -#include "llvm/Target/TargetLoweringObjectFile.h"
>>>> > -#include "llvm/Target/TargetRegistry.h"
>>>> > -#include "llvm/Support/raw_ostream.h"
>>>> > -using namespace llvm;
>>>> > -
>>>> > -namespace {
>>>> > -  class MSP430AsmPrinter : public AsmPrinter {
>>>> > -  public:
>>>> > -    MSP430AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
>>>> > -      : AsmPrinter(TM, Streamer) {}
>>>> > -
>>>> > -    virtual const char *getPassName() const {
>>>> > -      return "MSP430 Assembly Printer";
>>>> > -    }
>>>> > -
>>>> > -    void printOperand(const MachineInstr *MI, int OpNum,
>>>> > -                      raw_ostream &O, const char* Modifier = 0);
>>>> > -    void printSrcMemOperand(const MachineInstr *MI, int OpNum,
>>>> > -                            raw_ostream &O);
>>>> > -    bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
>>>> > -                         unsigned AsmVariant, const char *ExtraCode,
>>>> > -                         raw_ostream &O);
>>>> > -    bool PrintAsmMemoryOperand(const MachineInstr *MI,
>>>> > -                               unsigned OpNo, unsigned AsmVariant,
>>>> > -                               const char *ExtraCode, raw_ostream
>>>> &O);
>>>> > -    void EmitInstruction(const MachineInstr *MI);
>>>> > -  };
>>>> > -} // end of anonymous namespace
>>>> > -
>>>> > -
>>>> > -void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int
>>>> OpNum,
>>>> > -                                    raw_ostream &O, const char
>>>> *Modifier) {
>>>> > -  const MachineOperand &MO = MI->getOperand(OpNum);
>>>> > -  switch (MO.getType()) {
>>>> > -  default: assert(0 && "Not implemented yet!");
>>>> > -  case MachineOperand::MO_Register:
>>>> > -    O << MSP430InstPrinter::getRegisterName(MO.getReg());
>>>> > -    return;
>>>> > -  case MachineOperand::MO_Immediate:
>>>> > -    if (!Modifier || strcmp(Modifier, "nohash"))
>>>> > -      O << '#';
>>>> > -    O << MO.getImm();
>>>> > -    return;
>>>> > -  case MachineOperand::MO_MachineBasicBlock:
>>>> > -    O << *MO.getMBB()->getSymbol();
>>>> > -    return;
>>>> > -  case MachineOperand::MO_GlobalAddress: {
>>>> > -    bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
>>>> > -    uint64_t Offset = MO.getOffset();
>>>> > -
>>>> > -    // If the global address expression is a part of displacement
>>>> field with a
>>>> > -    // register base, we should not emit any prefix symbol here, e.g.
>>>> > -    //   mov.w &foo, r1
>>>> > -    // vs
>>>> > -    //   mov.w glb(r1), r2
>>>> > -    // Otherwise (!) msp430-as will silently miscompile the output :(
>>>> > -    if (!Modifier || strcmp(Modifier, "nohash"))
>>>> > -      O << (isMemOp ? '&' : '#');
>>>> > -    if (Offset)
>>>> > -      O << '(' << Offset << '+';
>>>> > -
>>>> > -    O << *Mang->getSymbol(MO.getGlobal());
>>>> > -
>>>> > -    if (Offset)
>>>> > -      O << ')';
>>>> > -
>>>> > -    return;
>>>> > -  }
>>>> > -  case MachineOperand::MO_ExternalSymbol: {
>>>> > -    bool isMemOp  = Modifier && !strcmp(Modifier, "mem");
>>>> > -    O << (isMemOp ? '&' : '#');
>>>> > -    O << MAI->getGlobalPrefix() << MO.getSymbolName();
>>>> > -    return;
>>>> > -  }
>>>> > -  }
>>>> > -}
>>>> > -
>>>> > -void MSP430AsmPrinter::printSrcMemOperand(const MachineInstr *MI, int
>>>> OpNum,
>>>> > -                                          raw_ostream &O) {
>>>> > -  const MachineOperand &Base = MI->getOperand(OpNum);
>>>> > -  const MachineOperand &Disp = MI->getOperand(OpNum+1);
>>>> > -
>>>> > -  // Print displacement first
>>>> > -
>>>> > -  // Imm here is in fact global address - print extra modifier.
>>>> > -  if (Disp.isImm() && !Base.getReg())
>>>> > -    O << '&';
>>>> > -  printOperand(MI, OpNum+1, O, "nohash");
>>>> > -
>>>> > -  // Print register base field
>>>> > -  if (Base.getReg()) {
>>>> > -    O << '(';
>>>> > -    printOperand(MI, OpNum, O);
>>>> > -    O << ')';
>>>> > -  }
>>>> > -}
>>>> > -
>>>> > -/// PrintAsmOperand - Print out an operand for an inline asm
>>>> expression.
>>>> > -///
>>>> > -bool MSP430AsmPrinter::PrintAsmOperand(const MachineInstr *MI,
>>>> unsigned OpNo,
>>>> > -                                       unsigned AsmVariant,
>>>> > -                                       const char *ExtraCode,
>>>> raw_ostream &O) {
>>>> > -  // Does this asm operand have a single letter operand modifier?
>>>> > -  if (ExtraCode && ExtraCode[0])
>>>> > -    return true; // Unknown modifier.
>>>> > -
>>>> > -  printOperand(MI, OpNo, O);
>>>> > -  return false;
>>>> > -}
>>>> > -
>>>> > -bool MSP430AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
>>>> > -                                             unsigned OpNo, unsigned
>>>> AsmVariant,
>>>> > -                                             const char *ExtraCode,
>>>> > -                                             raw_ostream &O) {
>>>> > -  if (ExtraCode && ExtraCode[0]) {
>>>> > -    return true; // Unknown modifier.
>>>> > -  }
>>>> > -  printSrcMemOperand(MI, OpNo, O);
>>>> > -  return false;
>>>> > -}
>>>> > -
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
>>>> > -  MSP430MCInstLower MCInstLowering(OutContext, *Mang, *this);
>>>> > -
>>>> > -  MCInst TmpInst;
>>>> > -  MCInstLowering.Lower(MI, TmpInst);
>>>> > -  OutStreamer.EmitInstruction(TmpInst);
>>>> > -}
>>>> > -
>>>> > -static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
>>>> > -                                                unsigned
>>>> SyntaxVariant,
>>>> > -                                                const MCAsmInfo &MAI)
>>>> {
>>>> > -  if (SyntaxVariant == 0)
>>>> > -    return new MSP430InstPrinter(MAI);
>>>> > -  return 0;
>>>> > -}
>>>> > -
>>>> > -// Force static initialization.
>>>> > -extern "C" void LLVMInitializeMSP430AsmPrinter() {
>>>> > -  RegisterAsmPrinter<MSP430AsmPrinter> X(TheMSP430Target);
>>>> > -  TargetRegistry::RegisterMCInstPrinter(TheMSP430Target,
>>>> > -                                        createMSP430MCInstPrinter);
>>>> > -}
>>>> >
>>>> > Modified: llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.cpp Fri Oct  1
>>>> 20:06:42 2010
>>>> > @@ -1,150 +0,0 @@
>>>> > -//===-- MSP430MCInstLower.cpp - Convert MSP430 MachineInstr to an
>>>> MCInst---===//
>>>> > -//
>>>> > -//                     The LLVM Compiler Infrastructure
>>>> > -//
>>>> > -// This file is distributed under the University of Illinois Open
>>>> Source
>>>> > -// License. See LICENSE.TXT for details.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -//
>>>> > -// This file contains code to lower MSP430 MachineInstrs to their
>>>> corresponding
>>>> > -// MCInst records.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -
>>>> > -#include "MSP430MCInstLower.h"
>>>> > -#include "llvm/CodeGen/AsmPrinter.h"
>>>> > -#include "llvm/CodeGen/MachineBasicBlock.h"
>>>> > -#include "llvm/CodeGen/MachineInstr.h"
>>>> > -#include "llvm/MC/MCAsmInfo.h"
>>>> > -#include "llvm/MC/MCContext.h"
>>>> > -#include "llvm/MC/MCExpr.h"
>>>> > -#include "llvm/MC/MCInst.h"
>>>> > -#include "llvm/Target/Mangler.h"
>>>> > -#include "llvm/Support/raw_ostream.h"
>>>> > -#include "llvm/Support/ErrorHandling.h"
>>>> > -#include "llvm/ADT/SmallString.h"
>>>> > -using namespace llvm;
>>>> > -
>>>> > -MCSymbol *MSP430MCInstLower::
>>>> > -GetGlobalAddressSymbol(const MachineOperand &MO) const {
>>>> > -  switch (MO.getTargetFlags()) {
>>>> > -  default: llvm_unreachable("Unknown target flag on GV operand");
>>>> > -  case 0: break;
>>>> > -  }
>>>> > -
>>>> > -  return Printer.Mang->getSymbol(MO.getGlobal());
>>>> > -}
>>>> > -
>>>> > -MCSymbol *MSP430MCInstLower::
>>>> > -GetExternalSymbolSymbol(const MachineOperand &MO) const {
>>>> > -  switch (MO.getTargetFlags()) {
>>>> > -  default: assert(0 && "Unknown target flag on GV operand");
>>>> > -  case 0: break;
>>>> > -  }
>>>> > -
>>>> > -  return Printer.GetExternalSymbolSymbol(MO.getSymbolName());
>>>> > -}
>>>> > -
>>>> > -MCSymbol *MSP430MCInstLower::
>>>> > -GetJumpTableSymbol(const MachineOperand &MO) const {
>>>> > -  SmallString<256> Name;
>>>> > -  raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix()
>>>> << "JTI"
>>>> > -                            << Printer.getFunctionNumber() << '_'
>>>> > -                            << MO.getIndex();
>>>> > -
>>>> > -  switch (MO.getTargetFlags()) {
>>>> > -  default: llvm_unreachable("Unknown target flag on GV operand");
>>>> > -  case 0: break;
>>>> > -  }
>>>> > -
>>>> > -  // Create a symbol for the name.
>>>> > -  return Ctx.GetOrCreateSymbol(Name.str());
>>>> > -}
>>>> > -
>>>> > -MCSymbol *MSP430MCInstLower::
>>>> > -GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
>>>> > -  SmallString<256> Name;
>>>> > -  raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix()
>>>> << "CPI"
>>>> > -                            << Printer.getFunctionNumber() << '_'
>>>> > -                            << MO.getIndex();
>>>> > -
>>>> > -  switch (MO.getTargetFlags()) {
>>>> > -  default: llvm_unreachable("Unknown target flag on GV operand");
>>>> > -  case 0: break;
>>>> > -  }
>>>> > -
>>>> > -  // Create a symbol for the name.
>>>> > -  return Ctx.GetOrCreateSymbol(Name.str());
>>>> > -}
>>>> > -
>>>> > -MCSymbol *MSP430MCInstLower::
>>>> > -GetBlockAddressSymbol(const MachineOperand &MO) const {
>>>> > -  switch (MO.getTargetFlags()) {
>>>> > -  default: assert(0 && "Unknown target flag on GV operand");
>>>> > -  case 0: break;
>>>> > -  }
>>>> > -
>>>> > -  return Printer.GetBlockAddressSymbol(MO.getBlockAddress());
>>>> > -}
>>>> > -
>>>> > -MCOperand MSP430MCInstLower::
>>>> > -LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const {
>>>> > -  // FIXME: We would like an efficient form for this, so we don't
>>>> have to do a
>>>> > -  // lot of extra uniquing.
>>>> > -  const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, Ctx);
>>>> > -
>>>> > -  switch (MO.getTargetFlags()) {
>>>> > -  default: llvm_unreachable("Unknown target flag on GV operand");
>>>> > -  case 0: break;
>>>> > -  }
>>>> > -
>>>> > -  if (!MO.isJTI() && MO.getOffset())
>>>> > -    Expr = MCBinaryExpr::CreateAdd(Expr,
>>>> > -
>>>> MCConstantExpr::Create(MO.getOffset(), Ctx),
>>>> > -                                   Ctx);
>>>> > -  return MCOperand::CreateExpr(Expr);
>>>> > -}
>>>> > -
>>>> > -void MSP430MCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI)
>>>> const {
>>>> > -  OutMI.setOpcode(MI->getOpcode());
>>>> > -
>>>> > -  for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
>>>> > -    const MachineOperand &MO = MI->getOperand(i);
>>>> > -
>>>> > -    MCOperand MCOp;
>>>> > -    switch (MO.getType()) {
>>>> > -    default:
>>>> > -      MI->dump();
>>>> > -      assert(0 && "unknown operand type");
>>>> > -    case MachineOperand::MO_Register:
>>>> > -      // Ignore all implicit register operands.
>>>> > -      if (MO.isImplicit()) continue;
>>>> > -      MCOp = MCOperand::CreateReg(MO.getReg());
>>>> > -      break;
>>>> > -    case MachineOperand::MO_Immediate:
>>>> > -      MCOp = MCOperand::CreateImm(MO.getImm());
>>>> > -      break;
>>>> > -    case MachineOperand::MO_MachineBasicBlock:
>>>> > -      MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
>>>> > -                         MO.getMBB()->getSymbol(), Ctx));
>>>> > -      break;
>>>> > -    case MachineOperand::MO_GlobalAddress:
>>>> > -      MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
>>>> > -      break;
>>>> > -    case MachineOperand::MO_ExternalSymbol:
>>>> > -      MCOp = LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
>>>> > -      break;
>>>> > -    case MachineOperand::MO_JumpTableIndex:
>>>> > -      MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
>>>> > -      break;
>>>> > -    case MachineOperand::MO_ConstantPoolIndex:
>>>> > -      MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
>>>> > -      break;
>>>> > -    case MachineOperand::MO_BlockAddress:
>>>> > -      MCOp = LowerSymbolOperand(MO, GetBlockAddressSymbol(MO));
>>>> > -    }
>>>> > -
>>>> > -    OutMI.addOperand(MCOp);
>>>> > -  }
>>>> > -}
>>>> >
>>>> > Modified: llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.h
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.h?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.h (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/MSP430MCInstLower.h Fri Oct  1
>>>> 20:06:42 2010
>>>> > @@ -1,50 +0,0 @@
>>>> > -//===-- MSP430MCInstLower.h - Lower MachineInstr to MCInst
>>>> ----------------===//
>>>> > -//
>>>> > -//                     The LLVM Compiler Infrastructure
>>>> > -//
>>>> > -// This file is distributed under the University of Illinois Open
>>>> Source
>>>> > -// License. See LICENSE.TXT for details.
>>>> > -//
>>>> >
>>>> -//===----------------------------------------------------------------------===//
>>>> > -
>>>> > -#ifndef MSP430_MCINSTLOWER_H
>>>> > -#define MSP430_MCINSTLOWER_H
>>>> > -
>>>> > -#include "llvm/Support/Compiler.h"
>>>> > -
>>>> > -namespace llvm {
>>>> > -  class AsmPrinter;
>>>> > -  class MCAsmInfo;
>>>> > -  class MCContext;
>>>> > -  class MCInst;
>>>> > -  class MCOperand;
>>>> > -  class MCSymbol;
>>>> > -  class MachineInstr;
>>>> > -  class MachineModuleInfoMachO;
>>>> > -  class MachineOperand;
>>>> > -  class Mangler;
>>>> > -
>>>> > -  /// MSP430MCInstLower - This class is used to lower an MachineInstr
>>>> > -  /// into an MCInst.
>>>> > -class LLVM_LIBRARY_VISIBILITY MSP430MCInstLower {
>>>> > -  MCContext &Ctx;
>>>> > -  Mangler &Mang;
>>>> > -
>>>> > -  AsmPrinter &Printer;
>>>> > -public:
>>>> > -  MSP430MCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter
>>>> &printer)
>>>> > -    : Ctx(ctx), Mang(mang), Printer(printer) {}
>>>> > -  void Lower(const MachineInstr *MI, MCInst &OutMI) const;
>>>> > -
>>>> > -  MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol
>>>> *Sym) const;
>>>> > -
>>>> > -  MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
>>>> > -  MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
>>>> > -  MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
>>>> > -  MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO)
>>>> const;
>>>> > -  MCSymbol *GetBlockAddressSymbol(const MachineOperand &MO) const;
>>>> > -};
>>>> > -
>>>> > -}
>>>> > -
>>>> > -#endif
>>>> >
>>>> > Modified: llvm/trunk/lib/Target/MSP430/Makefile
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/Makefile?rev=115393&r1=115392&r2=115393&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- llvm/trunk/lib/Target/MSP430/Makefile (original)
>>>> > +++ llvm/trunk/lib/Target/MSP430/Makefile Fri Oct  1 20:06:42 2010
>>>> > @@ -18,7 +18,7 @@
>>>> >               MSP430GenDAGISel.inc MSP430GenCallingConv.inc \
>>>> >               MSP430GenSubtarget.inc
>>>> >
>>>> > -DIRS = InstPrinter TargetInfo
>>>> > +DIRS = AsmPrinter TargetInfo
>>>> >
>>>> > include $(LEVEL)/Makefile.common
>>>> >
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > llvm-commits mailing list
>>>> > llvm-commits at cs.uiuc.edu
>>>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>
>>>
>>>
>>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101004/08cdbe41/attachment.html>


More information about the llvm-commits mailing list