2001-09-14 13:34:53 +08:00
|
|
|
//===-- TargetMachine.cpp - General Target Information ---------------------==//
|
2003-10-21 03:43:21 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-14 13:34:53 +08:00
|
|
|
//
|
|
|
|
// This file describes the general parts of a Target machine.
|
2002-12-29 10:50:35 +08:00
|
|
|
// This file also implements TargetCacheInfo.
|
2001-09-14 13:34:53 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-21 20:42:08 +08:00
|
|
|
|
2001-11-09 10:20:18 +08:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2002-12-29 10:50:35 +08:00
|
|
|
#include "llvm/Target/TargetCacheInfo.h"
|
2002-10-29 07:55:33 +08:00
|
|
|
#include "llvm/Type.h"
|
2003-12-29 05:23:38 +08:00
|
|
|
#include "llvm/IntrinsicLowering.h"
|
|
|
|
using namespace llvm;
|
2003-11-12 06:41:34 +08:00
|
|
|
|
2001-07-21 20:42:08 +08:00
|
|
|
//---------------------------------------------------------------------------
|
2003-12-29 05:23:38 +08:00
|
|
|
// TargetMachine Class
|
|
|
|
//
|
|
|
|
TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
|
|
|
|
bool LittleEndian,
|
|
|
|
unsigned char PtrSize, unsigned char PtrAl,
|
|
|
|
unsigned char DoubleAl, unsigned char FloatAl,
|
|
|
|
unsigned char LongAl, unsigned char IntAl,
|
|
|
|
unsigned char ShortAl, unsigned char ByteAl)
|
|
|
|
: Name(name), DataLayout(name, LittleEndian,
|
|
|
|
PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
|
|
|
|
IntAl, ShortAl, ByteAl) {
|
|
|
|
IL = il ? il : new DefaultIntrinsicLowering();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TargetMachine::~TargetMachine() {
|
|
|
|
delete IL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-21 20:42:08 +08:00
|
|
|
|
2001-09-18 20:58:33 +08:00
|
|
|
|
2002-10-30 05:47:50 +08:00
|
|
|
unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
|
2003-04-27 03:47:36 +08:00
|
|
|
// All integer types smaller than ints promote to 4 byte integers.
|
|
|
|
if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
|
|
|
|
return 4;
|
2002-10-30 05:47:50 +08:00
|
|
|
|
|
|
|
return DataLayout.getTypeSize(Ty);
|
2001-07-21 20:42:08 +08:00
|
|
|
}
|
|
|
|
|
2001-07-28 12:09:37 +08:00
|
|
|
|
2001-11-09 10:20:18 +08:00
|
|
|
//---------------------------------------------------------------------------
|
2003-12-29 05:23:38 +08:00
|
|
|
// TargetCacheInfo Class
|
|
|
|
//
|
2001-11-09 10:20:18 +08:00
|
|
|
|
2002-12-29 10:50:35 +08:00
|
|
|
void TargetCacheInfo::Initialize() {
|
2001-11-09 10:20:18 +08:00
|
|
|
numLevels = 2;
|
|
|
|
cacheLineSizes.push_back(16); cacheLineSizes.push_back(32);
|
|
|
|
cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
|
|
|
|
cacheAssoc.push_back(1); cacheAssoc.push_back(4);
|
|
|
|
}
|