+void AssemblyWriter::printAlias(const GlobalAlias *GA) {
+ Out << getLLVMName(GA->getName(), GlobalPrefix) << " = ";
+ switch (GA->getVisibility()) {
+ default: assert(0 && "Invalid visibility style!");
+ case GlobalValue::DefaultVisibility: break;
+ case GlobalValue::HiddenVisibility: Out << "hidden "; break;
+ case GlobalValue::ProtectedVisibility: Out << "protected "; break;
+ }
+
+ Out << "alias ";
+
+ switch (GA->getLinkage()) {
+ case GlobalValue::WeakLinkage: Out << "weak "; break;
+ case GlobalValue::InternalLinkage: Out << "internal "; break;
+ case GlobalValue::ExternalLinkage: break;
+ default:
+ assert(0 && "Invalid alias linkage");
+ }
+
+ const Constant *Aliasee = GA->getAliasee();
+
+ if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Aliasee)) {
+ printType(GV->getType());
+ Out << " " << getLLVMName(GV->getName(), GlobalPrefix);
+ } else if (const Function *F = dyn_cast<Function>(Aliasee)) {
+ printType(F->getFunctionType());
+ Out << "* ";
+
+ if (!F->getName().empty())
+ Out << getLLVMName(F->getName(), GlobalPrefix);
+ else
+ Out << "@\"\"";
+ } else {
+ const ConstantExpr *CE = 0;
+ if ((CE = dyn_cast<ConstantExpr>(Aliasee)) &&
+ (CE->getOpcode() == Instruction::BitCast)) {
+ writeOperand(CE, false);
+ } else
+ assert(0 && "Unsupported aliasee");
+ }
+
+ printInfoComment(*GA);
+ Out << "\n";
+}
+