1#include "AMDGPUMachineFunction.h"
2#include "AMDGPU.h"
3#include "llvm/IR/Attributes.h"
4#include "llvm/IR/Function.h"
5using namespace llvm;
6
7static const char *const ShaderTypeAttribute = "ShaderType";
8
9// Pin the vtable to this file.
10void AMDGPUMachineFunction::anchor() {}
11
12AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) :
13    MachineFunctionInfo() {
14  ShaderType = ShaderType::COMPUTE;
15  LDSSize = 0;
16  AttributeSet Set = MF.getFunction()->getAttributes();
17  Attribute A = Set.getAttribute(AttributeSet::FunctionIndex,
18                                 ShaderTypeAttribute);
19
20  if (A.isStringAttribute()) {
21    StringRef Str = A.getValueAsString();
22    if (Str.getAsInteger(0, ShaderType))
23      llvm_unreachable("Can't parse shader type!");
24  }
25}
26