[Mips] TargetStreamer Support for .set mips16.

This patch updates .set mips16 support which
affects the ELF ABI and its flags. In addition the patch uses
a common interface for both the MipsTargetSteamer and
MipsObjectStreamer that the assembler uses for
both ELF and ASCII output for these directives.

llvm-svn: 199851
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
index 909f9dc..786edf5 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
@@ -63,6 +63,12 @@
 void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
   OS << "\t.option\tpic0\n";
 }
+void MipsTargetAsmStreamer::emitDirectiveSetMips16(bool IsMips16) {
+  if (IsMips16)
+    OS << "\t.set\tmips16\n";
+  else
+    OS << "\t.set\tnomips16\n";
+}
 
 // This part is for ELF object output.
 MipsTargetELFStreamer::MipsTargetELFStreamer() : MicroMipsEnabled(false) {}
@@ -122,3 +128,13 @@
   Flags &= ~ELF::EF_MIPS_PIC;
   MCA.setELFHeaderEFlags(Flags);
 }
+void MipsTargetELFStreamer::emitDirectiveSetMips16(bool IsMips16) {
+  // Don't do anything for .set nomips16
+  if (!IsMips16)
+    return;
+
+  MCAssembler &MCA = getStreamer().getAssembler();
+  unsigned Flags = MCA.getELFHeaderEFlags();
+  Flags |= ELF::EF_MIPS_ARCH_ASE_M16;
+  MCA.setELFHeaderEFlags(Flags);
+}