R600/SI: Share code recording ShaderTypeAttribute between generations
[oota-llvm.git] / lib / Target / R600 / AMDGPUMachineFunction.cpp
1 #include "AMDGPUMachineFunction.h"
2 #include "llvm/IR/Attributes.h"
3 #include "llvm/IR/Function.h"
4
5 namespace llvm {
6
7 const char *AMDGPUMachineFunction::ShaderTypeAttribute = "ShaderType";
8
9 AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) :
10     MachineFunctionInfo() {
11   AttributeSet Set = MF.getFunction()->getAttributes();
12   Attribute A = Set.getAttribute(AttributeSet::FunctionIndex,
13                                  ShaderTypeAttribute);
14
15   if (A.isStringAttribute()) {
16     StringRef Str = A.getValueAsString();
17     if (Str.getAsInteger(0, ShaderType))
18       llvm_unreachable("Can't parse shader type!");
19   }
20 }
21
22 }