blob: 0f3f9e26528b8e70c57b21beed40874e896a591e [file] [log] [blame]
Vincent Lejeuneace6f732013-04-01 21:47:53 +00001#include "AMDGPUMachineFunction.h"
Tom Stellard456adc62013-04-26 18:32:24 +00002#include "AMDGPU.h"
Vincent Lejeuneace6f732013-04-01 21:47:53 +00003#include "llvm/IR/Attributes.h"
4#include "llvm/IR/Function.h"
Craig Topper8fc40962013-07-17 00:31:35 +00005using namespace llvm;
Vincent Lejeuneace6f732013-04-01 21:47:53 +00006
Craig Topper8fc40962013-07-17 00:31:35 +00007static const char *const ShaderTypeAttribute = "ShaderType";
Vincent Lejeuneace6f732013-04-01 21:47:53 +00008
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +00009// Pin the vtable to this file.
10void AMDGPUMachineFunction::anchor() {}
11
Vincent Lejeuneace6f732013-04-01 21:47:53 +000012AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) :
Matt Arsenault762af962014-07-13 03:06:39 +000013 MachineFunctionInfo(),
14 ShaderType(ShaderType::COMPUTE),
Matt Arsenault3f981402014-09-15 15:41:53 +000015 LDSSize(0),
16 ScratchSize(0),
17 IsKernel(true) {
Vincent Lejeuneace6f732013-04-01 21:47:53 +000018 AttributeSet Set = MF.getFunction()->getAttributes();
19 Attribute A = Set.getAttribute(AttributeSet::FunctionIndex,
20 ShaderTypeAttribute);
21
22 if (A.isStringAttribute()) {
23 StringRef Str = A.getValueAsString();
24 if (Str.getAsInteger(0, ShaderType))
25 llvm_unreachable("Can't parse shader type!");
26 }
27}