2001-09-14 05:34:53 +00:00
|
|
|
//===-- TargetMachine.cpp - General Target Information ---------------------==//
|
|
|
|
//
|
|
|
|
// This file describes the general parts of a Target machine.
|
2002-10-28 23:55:33 +00:00
|
|
|
// This file also implements MachineCacheInfo.
|
2001-09-14 05:34:53 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-21 12:42:08 +00:00
|
|
|
|
2001-11-09 02:20:18 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include "llvm/Target/MachineCacheInfo.h"
|
2002-10-28 23:55:33 +00:00
|
|
|
#include "llvm/Type.h"
|
2002-09-20 00:52:43 +00:00
|
|
|
|
2001-07-21 12:42:08 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2001-07-28 04:09:37 +00:00
|
|
|
// class TargetMachine
|
2001-07-21 12:42:08 +00:00
|
|
|
//
|
|
|
|
// Purpose:
|
2001-07-28 04:09:37 +00:00
|
|
|
// Machine description.
|
|
|
|
//
|
2001-07-21 12:42:08 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2001-09-18 12:58:33 +00:00
|
|
|
|
2001-07-28 04:09:37 +00:00
|
|
|
// function TargetMachine::findOptimalStorageSize
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// This default implementation assumes that all sub-word data items use
|
|
|
|
// space equal to optSizeForSubWordData, and all other primitive data
|
|
|
|
// items use space according to the type.
|
|
|
|
//
|
2001-09-18 12:58:33 +00:00
|
|
|
unsigned int
|
|
|
|
TargetMachine::findOptimalStorageSize(const Type* ty) const
|
|
|
|
{
|
|
|
|
switch(ty->getPrimitiveID())
|
|
|
|
{
|
|
|
|
case Type::BoolTyID:
|
|
|
|
case Type::UByteTyID:
|
|
|
|
case Type::SByteTyID:
|
|
|
|
case Type::UShortTyID:
|
|
|
|
case Type::ShortTyID:
|
|
|
|
return optSizeForSubWordData;
|
2001-07-21 12:42:08 +00:00
|
|
|
|
2001-09-18 12:58:33 +00:00
|
|
|
default:
|
|
|
|
return DataLayout.getTypeSize(ty);
|
|
|
|
}
|
2001-07-21 12:42:08 +00:00
|
|
|
}
|
|
|
|
|
2001-07-28 04:09:37 +00:00
|
|
|
|
2001-11-09 02:20:18 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// class MachineCacheInfo
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Describes properties of the target cache architecture.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2002-10-28 23:55:33 +00:00
|
|
|
void MachineCacheInfo::Initialize() {
|
2001-11-09 02:20:18 +00: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);
|
|
|
|
}
|