~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===-- ARMMCInstLower.cpp - Convert ARM MachineInstr to an MCInst --------===//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file contains code to lower ARM MachineInstrs to their corresponding
 
11
// MCInst records.
 
12
//
 
13
//===----------------------------------------------------------------------===//
 
14
 
 
15
#include "ARMMCInstLower.h"
 
16
//#include "llvm/CodeGen/MachineModuleInfoImpls.h"
 
17
#include "llvm/CodeGen/AsmPrinter.h"
 
18
#include "llvm/CodeGen/MachineBasicBlock.h"
 
19
#include "llvm/MC/MCAsmInfo.h"
 
20
#include "llvm/MC/MCContext.h"
 
21
#include "llvm/MC/MCExpr.h"
 
22
#include "llvm/MC/MCInst.h"
 
23
//#include "llvm/MC/MCStreamer.h"
 
24
#include "llvm/Support/raw_ostream.h"
 
25
#include "llvm/ADT/SmallString.h"
 
26
using namespace llvm;
 
27
 
 
28
 
 
29
#if 0
 
30
const ARMSubtarget &ARMMCInstLower::getSubtarget() const {
 
31
  return AsmPrinter.getSubtarget();
 
32
}
 
33
 
 
34
MachineModuleInfoMachO &ARMMCInstLower::getMachOMMI() const {
 
35
  assert(getSubtarget().isTargetDarwin() &&"Can only get MachO info on darwin");
 
36
  return AsmPrinter.MMI->getObjFileInfo<MachineModuleInfoMachO>(); 
 
37
}
 
38
#endif
 
39
 
 
40
MCSymbol *ARMMCInstLower::
 
41
GetGlobalAddressSymbol(const MachineOperand &MO) const {
 
42
  // FIXME: HANDLE PLT references how??
 
43
  switch (MO.getTargetFlags()) {
 
44
  default: assert(0 && "Unknown target flag on GV operand");
 
45
  case 0: break;
 
46
  }
 
47
  
 
48
  return Printer.GetGlobalValueSymbol(MO.getGlobal());
 
49
}
 
50
 
 
51
MCSymbol *ARMMCInstLower::
 
52
GetExternalSymbolSymbol(const MachineOperand &MO) const {
 
53
  // FIXME: HANDLE PLT references how??
 
54
  switch (MO.getTargetFlags()) {
 
55
  default: assert(0 && "Unknown target flag on GV operand");
 
56
  case 0: break;
 
57
  }
 
58
  
 
59
  return Printer.GetExternalSymbolSymbol(MO.getSymbolName());
 
60
}
 
61
 
 
62
 
 
63
 
 
64
MCSymbol *ARMMCInstLower::
 
65
GetJumpTableSymbol(const MachineOperand &MO) const {
 
66
  SmallString<256> Name;
 
67
  raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "JTI"
 
68
    << Printer.getFunctionNumber() << '_' << MO.getIndex();
 
69
  
 
70
#if 0
 
71
  switch (MO.getTargetFlags()) {
 
72
    default: llvm_unreachable("Unknown target flag on GV operand");
 
73
  }
 
74
#endif
 
75
  
 
76
  // Create a symbol for the name.
 
77
  return Ctx.GetOrCreateSymbol(Name.str());
 
78
}
 
79
 
 
80
MCSymbol *ARMMCInstLower::
 
81
GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
 
82
  SmallString<256> Name;
 
83
  raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "CPI"
 
84
    << Printer.getFunctionNumber() << '_' << MO.getIndex();
 
85
  
 
86
#if 0
 
87
  switch (MO.getTargetFlags()) {
 
88
  default: llvm_unreachable("Unknown target flag on GV operand");
 
89
  }
 
90
#endif
 
91
  
 
92
  // Create a symbol for the name.
 
93
  return Ctx.GetOrCreateSymbol(Name.str());
 
94
}
 
95
  
 
96
MCOperand ARMMCInstLower::
 
97
LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const {
 
98
  // FIXME: We would like an efficient form for this, so we don't have to do a
 
99
  // lot of extra uniquing.
 
100
  const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, Ctx);
 
101
  
 
102
#if 0
 
103
  switch (MO.getTargetFlags()) {
 
104
  default: llvm_unreachable("Unknown target flag on GV operand");
 
105
  }
 
106
#endif
 
107
  
 
108
  if (!MO.isJTI() && MO.getOffset())
 
109
    Expr = MCBinaryExpr::CreateAdd(Expr,
 
110
                                   MCConstantExpr::Create(MO.getOffset(), Ctx),
 
111
                                   Ctx);
 
112
  return MCOperand::CreateExpr(Expr);
 
113
}
 
114
 
 
115
 
 
116
void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
 
117
  OutMI.setOpcode(MI->getOpcode());
 
118
  
 
119
  for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
 
120
    const MachineOperand &MO = MI->getOperand(i);
 
121
    
 
122
    MCOperand MCOp;
 
123
    switch (MO.getType()) {
 
124
    default:
 
125
      MI->dump();
 
126
      assert(0 && "unknown operand type");
 
127
    case MachineOperand::MO_Register:
 
128
      // Ignore all implicit register operands.
 
129
      if (MO.isImplicit()) continue;
 
130
      assert(!MO.getSubReg() && "Subregs should be eliminated!");
 
131
      MCOp = MCOperand::CreateReg(MO.getReg());
 
132
      break;
 
133
    case MachineOperand::MO_Immediate:
 
134
      MCOp = MCOperand::CreateImm(MO.getImm());
 
135
      break;
 
136
    case MachineOperand::MO_MachineBasicBlock:
 
137
      MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
 
138
                       MO.getMBB()->getSymbol(Ctx), Ctx));
 
139
      break;
 
140
    case MachineOperand::MO_GlobalAddress:
 
141
      MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
 
142
      break;
 
143
    case MachineOperand::MO_ExternalSymbol:
 
144
      MCOp = LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
 
145
      break;
 
146
    case MachineOperand::MO_JumpTableIndex:
 
147
      MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
 
148
      break;
 
149
    case MachineOperand::MO_ConstantPoolIndex:
 
150
      MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
 
151
      break;
 
152
    case MachineOperand::MO_BlockAddress:
 
153
      MCOp = LowerSymbolOperand(MO, Printer.GetBlockAddressSymbol(
 
154
                                              MO.getBlockAddress()));
 
155
      break;
 
156
    }
 
157
    
 
158
    OutMI.addOperand(MCOp);
 
159
  }
 
160
  
 
161
}