[llvm] r270171 - Add AVRTargetStreamers
Dylan McKay via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 18:17:39 PDT 2016
Author: dylanmckay
Date: Thu May 19 20:17:38 2016
New Revision: 270171
URL: http://llvm.org/viewvc/llvm-project?rev=270171&view=rev
Log:
Add AVRTargetStreamers
Reviewed by Matt Arsenault in http://reviews.llvm.org/D16311
Added:
llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.cpp
llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.h
llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h
llvm/trunk/lib/Target/AVR/MCTargetDesc/CMakeLists.txt
llvm/trunk/lib/Target/AVR/MCTargetDesc/LLVMBuild.txt
Added: llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.cpp?rev=270171&view=auto
==============================================================================
--- llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.cpp (added)
+++ llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.cpp Thu May 19 20:17:38 2016
@@ -0,0 +1,60 @@
+#include "AVRELFStreamer.h"
+
+#include "llvm/Support/ELF.h"
+#include "llvm/Support/FormattedStream.h"
+
+static unsigned getEFlagsForFeatureSet(const FeatureBitset &Features) {
+ unsigned EFlags = 0;
+
+ // Set architecture
+ if (Features[AVR::ELFArchAVR1])
+ EFlags |= ELF::EF_AVR_ARCH_AVR1;
+ else if (Features[AVR::ELFArchAVR2])
+ EFlags |= ELF::EF_AVR_ARCH_AVR2;
+ else if (Features[AVR::ELFArchAVR25])
+ EFlags |= ELF::EF_AVR_ARCH_AVR25;
+ else if (Features[AVR::ELFArchAVR3])
+ EFlags |= ELF::EF_AVR_ARCH_AVR3;
+ else if (Features[AVR::ELFArchAVR31])
+ EFlags |= ELF::EF_AVR_ARCH_AVR31;
+ else if (Features[AVR::ELFArchAVR35])
+ EFlags |= ELF::EF_AVR_ARCH_AVR35;
+ else if (Features[AVR::ELFArchAVR4])
+ EFlags |= ELF::EF_AVR_ARCH_AVR4;
+ else if (Features[AVR::ELFArchAVR5])
+ EFlags |= ELF::EF_AVR_ARCH_AVR5;
+ else if (Features[AVR::ELFArchAVR51])
+ EFlags |= ELF::EF_AVR_ARCH_AVR51;
+ else if (Features[AVR::ELFArchAVR6])
+ EFlags |= ELF::EF_AVR_ARCH_AVR6;
+ else if (Features[AVR::ELFArchAVRTiny])
+ EFlags |= ELF::EF_AVR_ARCH_AVRTINY;
+ else if (Features[AVR::ELFArchXMEGA1])
+ EFlags |= ELF::EF_AVR_ARCH_XMEGA1;
+ else if (Features[AVR::ELFArchXMEGA2])
+ EFlags |= ELF::EF_AVR_ARCH_XMEGA2;
+ else if (Features[AVR::ELFArchXMEGA3])
+ EFlags |= ELF::EF_AVR_ARCH_XMEGA3;
+ else if (Features[AVR::ELFArchXMEGA4])
+ EFlags |= ELF::EF_AVR_ARCH_XMEGA4;
+ else if (Features[AVR::ELFArchXMEGA5])
+ EFlags |= ELF::EF_AVR_ARCH_XMEGA5;
+ else if (Features[AVR::ELFArchXMEGA6])
+ EFlags |= ELF::EF_AVR_ARCH_XMEGA6;
+ else if (Features[AVR::ELFArchXMEGA7])
+ EFlags |= ELF::EF_AVR_ARCH_XMEGA7;
+
+ return EFlags;
+}
+
+AVRELFStreamer::AVRELFStreamer(MCStreamer &S,
+ const MCSubtargetInfo &STI)
+ : AVRTargetStreamer(S) {
+
+ MCAssembler &MCA = getStreamer().getAssembler();
+ unsigned EFlags = MCA.getELFHeaderEFlags(Features);
+
+ EFlags |= getEFlagsForFeatureSet(STI.getFeatureBits())
+
+ MCA.setELFHeaderEFlags(EFlags);
+}
Added: llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.h?rev=270171&view=auto
==============================================================================
--- llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.h (added)
+++ llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRELFStreamer.h Thu May 19 20:17:38 2016
@@ -0,0 +1,27 @@
+//===----- AVRELFStreamer.h - AVR Target Streamer --------------*- C++ -*--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_AVR_ELF_STREAMER_H
+#define LLVM_AVR_ELF_STREAMER_H
+
+#include "AVRTargetStreamer.h"
+
+#include "llvm/MC/MCELFStreamer.h"
+
+/// A target streamer for an AVR ELF object file.
+class AVRELFStreamer : public AVRTargetStreamer {
+public:
+ AVRELFStreamer(MCStreamer &S, const MCSubtargetInfo &STI);
+
+ MCELFStreamer &getStreamer() {
+ return static_cast<MCELFStreamer &>(Streamer);
+ }
+};
+
+#endif
Added: llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h?rev=270171&view=auto
==============================================================================
--- llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h (added)
+++ llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRTargetStreamer.h Thu May 19 20:17:38 2016
@@ -0,0 +1,30 @@
+//===-- AVRTargetStreamer.h - AVR Target Streamer --------------*- C++ -*--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_AVR_TARGET_STREAMER_H
+#define LLVM_AVR_TARGET_STREAMER_H
+
+namespace llvm {
+class MCStreamer;
+
+/// A generic AVR target output stream.
+class AVRTargetStreamer : public MCTargetStreamer {
+public:
+ explicit AVRTargetStreamer(MCStreamer &S);
+};
+
+/// A target streamer for textual AVR assembly code.
+class AVRTargetAsmStreamer : public AVRTargetStreamer {
+public:
+ explicit AVRTargetAsmStreamer(MCStreamer &S);
+};
+
+} // end namespace llvm
+
+#endif // LLVM_AVR_TARGET_STREAMER_H
Added: llvm/trunk/lib/Target/AVR/MCTargetDesc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/MCTargetDesc/CMakeLists.txt?rev=270171&view=auto
==============================================================================
--- llvm/trunk/lib/Target/AVR/MCTargetDesc/CMakeLists.txt (added)
+++ llvm/trunk/lib/Target/AVR/MCTargetDesc/CMakeLists.txt Thu May 19 20:17:38 2016
@@ -0,0 +1,7 @@
+add_llvm_library(LLVMAVRDesc
+ AVRTargetStreamer.cpp
+ AVRELFStreamer.cpp
+)
+
+add_dependencies(LLVMAVRDesc AVRCommonTableGen)
+
Added: llvm/trunk/lib/Target/AVR/MCTargetDesc/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/MCTargetDesc/LLVMBuild.txt?rev=270171&view=auto
==============================================================================
--- llvm/trunk/lib/Target/AVR/MCTargetDesc/LLVMBuild.txt (added)
+++ llvm/trunk/lib/Target/AVR/MCTargetDesc/LLVMBuild.txt Thu May 19 20:17:38 2016
@@ -0,0 +1,23 @@
+;===- ./lib/Target/AVR/MCTargetDesc/LLVMBuild.txt --------------*- Conf -*--===;
+;
+; The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+; http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Library
+name = AVRDesc
+parent = AVR
+required_libraries = MC AVRInfo Support
+add_to_library_groups = AVR
More information about the llvm-commits
mailing list