It's not legal to fold a load from a narrower stack slot into a wider instruction...
[llvm/avr.git] / lib / AsmParser / Parser.cpp
blob331a23323b517214156d78b62505d3ec1ea3a334
1 //===- Parser.cpp - Main dispatch module for the Parser library -----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This library implements the functionality defined in llvm/Assembly/Parser.h
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Assembly/Parser.h"
15 #include "LLParser.h"
16 #include "llvm/Module.h"
17 #include "llvm/ADT/OwningPtr.h"
18 #include "llvm/Support/SourceMgr.h"
19 #include "llvm/Support/MemoryBuffer.h"
20 #include "llvm/Support/raw_ostream.h"
21 #include <cstring>
22 using namespace llvm;
24 Module *llvm::ParseAssembly(MemoryBuffer *F,
25 Module *M,
26 SMDiagnostic &Err,
27 LLVMContext &Context) {
28 SourceMgr SM;
29 SM.AddNewSourceBuffer(F, SMLoc());
31 // If we are parsing into an existing module, do it.
32 if (M)
33 return LLParser(F, SM, Err, M).Run() ? 0 : M;
35 // Otherwise create a new module.
36 OwningPtr<Module> M2(new Module(F->getBufferIdentifier(), Context));
37 if (LLParser(F, SM, Err, M2.get()).Run())
38 return 0;
39 return M2.take();
42 Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
43 LLVMContext &Context) {
44 std::string ErrorStr;
45 MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr);
46 if (F == 0) {
47 Err = SMDiagnostic("", -1, -1,
48 "Could not open input file '" + Filename + "'", "");
49 return 0;
52 return ParseAssembly(F, 0, Err, Context);
55 Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
56 SMDiagnostic &Err, LLVMContext &Context) {
57 MemoryBuffer *F =
58 MemoryBuffer::getMemBuffer(AsmString, AsmString+strlen(AsmString),
59 "<string>");
61 return ParseAssembly(F, M, Err, Context);